Build of GHC 9.6 fails when the build directory is not a child of the source directory

Viktor Dukhovni ietf-dane at dukhovni.org
Sun Apr 30 01:00:55 UTC 2023


For some time now I'd been unable to build GHC 9.6 from source.  The
reason turned out to be that my hadrian command-line selected an
explicit build directory that was not an immediate child of the source
directory (default it seems is "_build").

With the source tree under "$HOME/dev/ghc/", the hardrian command

    $ hadrian/build -V -V -o"$HOME/dev/buildghc" --docs=no-sphinx binary-dist-dir

after building stage0, and running "configure" in libraries/base,
reports an error finding HsFFI.h:

    Reading parameters from $HOME/dev/buildghc/stage1/libraries/base/build/base.buildinfo
    /usr/bin/cc '-fuse-ld=gold' /tmp/2303653-4.c -o /tmp/2303653-5
        '-D__GLASGOW_HASKELL__=906' \
        '-Dlinux_BUILD_OS=1' \
        '-Dx86_64_BUILD_ARCH=1' \
        '-Dlinux_HOST_OS=1' \
        '-Dx86_64_HOST_ARCH=1' \
        -I$HOME/dev/buildghc/stage1/libraries/base/build/autogen \
        -I$HOME/dev/buildghc/stage1/libraries/base/build/include \
        -Ilibraries/base/include \
        -Ilibraries/base \
        -I/usr/include \
        -I$HOME/dev/buildghc/stage1/inplace/../../..//libraries/ghc-bignum/include/ \
        -I$HOME/dev/buildghc/stage1/libraries/ghc-bignum/build/include/ \
        -I$HOME/dev/buildghc/stage1/inplace/../../..//libraries/ghc-bignum/include \
        -I$HOME/dev/buildghc/stage1/libraries/ghc-bignum/build/include \
        -I$HOME/dev/buildghc/stage1/inplace/../../..//rts/include \
        -I$HOME/dev/buildghc/stage1/rts/build/include \
        '-I$HOME/dev/buildghc/stage1/inplace/../../..//rts/@FFIIncludeDir@' \
        '-I$HOME/dev/buildghc/stage1/rts/build/@FFIIncludeDir@' \
        '-I$HOME/dev/buildghc/stage1/inplace/../../..//rts/@LibdwIncludeDir@' \
        '-I$HOME/dev/buildghc/stage1/rts/build/@LibdwIncludeDir@' \
        -L$HOME/dev/buildghc/stage1/inplace/../libraries/ghc-bignum/build \
        -L$HOME/dev/buildghc/stage1/inplace/../libraries/ghc-prim/build \
        -L$HOME/dev/buildghc/stage1/inplace/../rts/build -iquote \
        $HOME/dev/ghc/libraries/base \
        '-fuse-ld=gold'

There are two issues to note here:

    - "hadrian" fails to substitute @FFIIncludeDir@ and @LibdwIncludeDir at .
      This used to be handled by "configure", but the job of turning
      "rts.cabal.in" into "rts.cabal" seems to have been reassigned to
      "hadrian".

    - With the build output directory a sibling rather than a child of
      the source tree, the path to "rts/include" is not constructed
      correctly.  The path:

        -I$HOME/dev/buildghc/stage1/inplace/../../..//rts/include

      should have been:

        -I$HOME/dev/buildghc/stage1/inplace/../../../ghc/rts/include

Switching to the default path proved to be a viable work-around, but
perhaps other choices should also work.

-- 
    Viktor.


More information about the ghc-devs mailing list