Skip to content

building GHC overwrites the installed package database if GHC_PACKAGE_PATH is set

When building GHC, if GHC_PACKAGE_PATH is set to a single path, then the build process will register packages in that path instead of in the build tree. Since GHC_PACKAGE_PATH points to the host compiler's package database, the build system overwrites the host compiler's package database, rendering the host compiler unusable.

To reproduce:

  1. Get a binary distribution of GHC 7.4.1 and a source distribution of GHC 7.4.2
  2. Configure the binary distribution to install in a temporary directory: ./configure --prefix=$HOME/workspace1
  3. Install the binary distribution
  4. Set up the environment to use only the installed compiler: export PATH=$HOME/workspace1/bin:$PATH; export GHC_PACKAGE_PATH=$HOME/workspace1/lib/ghc-7.4.1/package.conf.d
  5. Configure the source distribution to install in a different directory: ./configure --prefix=$HOME/workspace2
  6. Build the source distribution: make

Building will eventually run commands that modify the package database in GHC_PACKAGE_PATH. One of these commands is "inplace/bin/ghc-pkg" update --force rts/package.conf.inplace. I confirmed that the database is being modified by making ghc-pkg print the name of the file it's about to update.

Trac metadata
Trac field Value
Version 7.4.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Build System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information