Read global package database from settings file
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 stage1 libraries, so we should set "Global Package DB" for the stage1 compiler to the stage1 package database. * Stage 2 cross compilers need to use stage2 libraries, so likewise, we should set the package database path to `_build/stage2/lib/` * The normal situation is where the stage2 compiler uses stage1 libraries. Then everything lines up. * 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. In this case we set the relative package db path to `package.conf.d`, so it resolves the same as before. * ghc-pkg needs to be modified as well to look in the settings file fo the package database rather than assuming the global package database location relative to the lib folder. * 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). In short, this 10 line patch allows for some reasonable simplifications in Hadrian at very little cost to anything else. Fixes #24502
Showing
- compiler/GHC/Driver/Session.hs 2 additions, 1 deletioncompiler/GHC/Driver/Session.hs
- compiler/GHC/Settings/IO.hs 8 additions, 2 deletionscompiler/GHC/Settings/IO.hs
- hadrian/bindist/Makefile 1 addition, 0 deletionshadrian/bindist/Makefile
- hadrian/src/Rules/Generate.hs 1 addition, 0 deletionshadrian/src/Rules/Generate.hs
- libraries/ghc-boot/GHC/Settings/Utils.hs 7 additions, 0 deletionslibraries/ghc-boot/GHC/Settings/Utils.hs
- utils/ghc-pkg/Main.hs 46 additions, 22 deletionsutils/ghc-pkg/Main.hs
Loading
Please register or sign in to comment