summaryrefslogtreecommitdiff
path: root/hadrian/src
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2020-11-20 16:58:28 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-11-28 15:40:23 -0500
commit7cb5df9617544dc3bdf85b719feaaa5d15f01c2c (patch)
tree9a5d9b80339bbb51d412760d914e2b013e856898 /hadrian/src
parent75fc1ed58bb9adb3f472e1529d368c0fff479353 (diff)
downloadhaskell-7cb5df9617544dc3bdf85b719feaaa5d15f01c2c.tar.gz
hadrian: fix ghc-pkg uses (#17601)
Make sure ghc-pkg doesn't read the compiler "settings" file by passing --no-user-package-db.
Diffstat (limited to 'hadrian/src')
-rw-r--r--hadrian/src/Settings/Builders/GhcPkg.hs30
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
+ ]
+