diff options
-rw-r--r-- | hadrian/src/Settings/Builders/GhcPkg.hs | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/hadrian/src/Settings/Builders/GhcPkg.hs b/hadrian/src/Settings/Builders/GhcPkg.hs index 9223a9d85a..8b9d28f6b5 100644 --- a/hadrian/src/Settings/Builders/GhcPkg.hs +++ b/hadrian/src/Settings/Builders/GhcPkg.hs @@ -8,8 +8,7 @@ ghcPkgBuilderArgs = mconcat verbosity <- expr getVerbosity stage <- getStage pkgDb <- expr $ packageDbPath stage - mconcat [ arg "--global-package-db" - , arg pkgDb + mconcat [ use_db pkgDb , arg "register" , verbosity < Chatty ? arg "-v0" ] @@ -17,8 +16,7 @@ ghcPkgBuilderArgs = mconcat verbosity <- expr getVerbosity stage <- getStage pkgDb <- expr $ packageDbPath stage - mconcat [ arg "--global-package-db" - , arg pkgDb + mconcat [ use_db pkgDb , arg "unregister" , arg "--force" , verbosity < Chatty ? arg "-v0" @@ -29,10 +27,30 @@ ghcPkgBuilderArgs = mconcat config <- expr $ pkgInplaceConfig context stage <- getStage pkgDb <- expr $ packageDbPath stage - mconcat [ notStage0 ? arg "--global-package-db" - , notStage0 ? arg pkgDb + mconcat [ notStage0 ? use_db pkgDb , arg "update" , arg "--force" , verbosity < Chatty ? arg "-v0" , bootPackageDatabaseArgs , arg config ] ] + where + use_db db = mconcat + -- We use ghc-pkg's --global-package-db to manipulate our databases. + -- We can't use --package-db (at least with stage0's ghc-pkg) + -- because units in stage0's global package db would be in scope and + -- ghc-pkg would disallow us the register a second "rts" unit in our + -- database. + -- + -- However ghc-pkg uses the path to the global package db to find + -- the compiler "settings" file... So when it finds our newly + -- generated settings file in _build/stageN, it may crash if it + -- isn't the format it expects (#17601). + -- + -- By chance, ghc-pkg only needs the "settings" file to query the + -- arch/os to generate the path to the user package db, which we + -- don't need. So we disable it below to avoid failures. + [ arg "--no-user-package-db" + , arg "--global-package-db" + , arg db + ] + |