Store relative path to package database in settings file
MR: !12163 (closed)
cc @hsyl20
Before this patch, the global package database was always assumed to be in libdir </> package.conf.d.
This causes issues in GHC's build system because there are sometimes situations where the package database you need to use is not located in the same place as the settings file.
-
The stage1 compiler needs to use stage2 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage2 package database.
-
Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database to point to
_build/stage2/lib
. -
When installing we have rearranged everything so that the settings file and package database line up properly, so then everything should continue to work as before. (So we just set the package path to "package.conf.d", so things work the same as before).
-
ghc-pkg needs to be modified as well to look in the settings file for the package database rather than assuming the global package database location relative to the lib folder. This just seems like an improvement to me.
-
Cabal/cabal-install will work correctly because they query the global package database using
--print-global-package-db
.
A reasonable question is why not generate the "right" settings files in the right places in GHC's build system. In order to do this you would need to engineer wrappers for all executables to point to a specific libdir. There are also situations where the same package db is used by two different compilers with two different settings files (think stage2 cross compiler and stage3 compiler).
Note that this patch then allows us to also delete the stage1 wrappers, so you can run the stage1 executable normally and it will work and look in the right package database.
In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else.