Skip to content

Non-hermetic build "Couldn't find #define HS_CONSTANTS"

Summary

Building ghc-9.2.1-rc1 on OpenBSD fails with:

===--- building phase 0
gmake --no-print-directory -f ghc.mk phase=0 phase_0_builds
gmake[1]: Nothing to be done for 'phase_0_builds'.
===--- building phase 1
gmake --no-print-directory -f ghc.mk phase=1 phase_1_builds
gmake[1]: Nothing to be done for 'phase_1_builds'.
===--- building final phase
gmake --no-print-directory -f ghc.mk phase=final install

... below reflowed for clarity

"inplace/bin/ghc-cabal" register libraries/ghc-prim dist-install \
   "/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc" \
   "/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc-pkg" \
   "/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc" \
   '/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64' \
   '/usr/local' '/usr/local/lib/ghc' '/usr/local/share/doc/ghc/html/libraries' \
   NO
ghc-cabal:
'/usr/ports/pobj/ghc-9.2.0.20210821/fake-amd64/usr/local/lib/ghc/bin/ghc'
exited with an error:
ghc: panic! (the 'impossible' happened)
(GHC version 9.2.0.20210821:
Couldn't find #define HS_CONSTANTS " in
/usr/local/lib/ghc/include/DerivedConstants.h
CallStack (from HasCallStack):
error, called at compiler/stage2/build/GHC/Platform/Constants.hs:143:20 in
ghc:GHC.Platform.Constants

Notice the reported file path: /usr/local/lib/ghc is the previous version of ghc installed on the system and isn't even supposed to be used by the build (because the bootstrap is provided separately). I would expect the intermediate (fake) installation directory to be used everywhere in the install process, but something isn't hermetic.

This used to work with 9.2.1-alpha1 package which I previously built from https://github.com/blackgnezdo/ports/commits/ghc-9.2 (almost, the libHSrts_l hack isn't automated on that branch). The timeline is aligned with the submission of 9c762f27 which makes it a likely culprit (FYI @hsyl20).

Steps to reproduce

The ports tree snapshot is at https://github.com/blackgnezdo/ports/commits/ghc-9.2.1-rc1. Running make package in lang/ghc should be enough to reproduce.

Expected behavior

A working build independent of the previously installed local system packages.

Environment

  • GHC version used: 8.10.3 is used as a bootstrap

Optional:

  • Operating System: OpenBSD 7.0-beta
  • System Architecture: amd64
Edited by Greg Steuck
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information