Skip to content

autoconf constants undefined in ghc-prim stage2 build

Summary

When building ghc-prim in Stage 2 I get errors like:

In file included from rts/include/Rts.h:23,
                 from libraries/ghc-prim/cbits/clz.c:2:
rts/include/stg/Types.h:147:2: error: #error GHC untested on this architecture: sizeof(void *) != 4 or 8
  147 | #error GHC untested on this architecture: sizeof(void *) != 4 or 8
      |  ^~~~~
In file included from rts/include/stg/MachRegsForHost.h:76,
                 from rts/include/Stg.h:335,
                 from rts/include/Rts.h:35,
                 from libraries/ghc-prim/cbits/clz.c:2:
rts/include/stg/MachRegs.h:596:2: error: #error Cannot find platform to give register info for
  596 | #error Cannot find platform to give register info for
      |  ^~~~~
In file included from rts/include/Rts.h:215,
                 from libraries/ghc-prim/cbits/clz.c:2:
rts/include/rts/Constants.h:191:2: error: #error unknown SIZEOF_VOID_P
  191 | #error unknown SIZEOF_VOID_P
      |  ^~~~~
libraries/ghc-prim/cbits/clz.c:28:3: error: #error no suitable __builtin_clz() found
   28 | # error no suitable __builtin_clz() found
      |   ^~~~~
libraries/ghc-prim/cbits/clz.c:39:3: error: #error no suitable __builtin_clz() found
   39 | # error no suitable __builtin_clz() found
      |   ^~~~~
Command failed

A quick test with #ifndef shows that the constants from ghcautoconf.h are undefined at that point.

git bisect revealed the commit that introduces this bug to be:

commit b42cedbefb296437014d0768348b740b960943c0 (HEAD)
Author: Matthew Pickering <matthewtpickering@gmail.com>
Date:   Sun Aug 21 19:34:36 2022 +0100

    hadrian: Inplace/Final package databases

I'm using ghc.nix at b23615d4ed80da638dec87eebe3452d460ea086f.

Steps to reproduce

git checkout --recurse-submodules b42cedbefb296437014d0768348b740b960943c0
nix develop github:alpmestan/ghc.nix
./boot
configure_ghc
hadrian/build --flavour=quickest --build-root=builds/quickest stage2:lib:ghc-prim

Environment

Optional:

  • Operating System: NixOS unstable
  • System Architecture: x86_64

EDIT: I noticed that it only happens when using --build-root with a subdirectory like builds/quickest.

Edited by Torsten Schmits
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information