--with-system-libffi without --with-ffi-includes breaks hadrian build
If GHC is configured with --with-system-libffi
without --with-ffi-includes
, hadrian build will fail with:
| Package 'rts' configuration flags: configure --distdir /builds/project-0/_build/stage1/rts --disable-executable-stripping --disable-library-stripping --cabal-file rts/rts.cabal --ipid $pkg-$version --prefix ${pkgroot}/.. --htmldir ${pkgroot}/../../docs/html/libraries/rts --with-ghc=/builds/project-0/_build/stage0/bin/ghc --ghc-option=-no-global-package-db --ghc-option=-package-db=/builds/project-0/_build/stage1/lib/package.conf.d --with-ghc-pkg=/builds/project-0/_build/stage0/bin/ghc-pkg --ghc-pkg-option=--global-package-db=/builds/project-0/_build/stage1/lib/package.conf.d --enable-library-vanilla --disable-library-profiling --disable-library-for-ghci --enable-shared --with-gcc=/usr/bin/gcc --with-ld=/usr/bin/ld --with-ar=/usr/bin/ar --with-alex=/opt/toolchain/bin/alex --with-happy=/opt/toolchain/bin/happy --configure-option=CFLAGS=-iquote /builds/project-0/rts --gcc-options=-iquote /builds/project-0/rts --configure-option=--host=x86_64-unknown-linux --configure-option=--with-cc=/usr/bin/gcc --ghc-option=-ghcversion-file=rts/include/ghcversion.h --ghc-option=-ghcversion-file=rts/include/ghcversion.h --flags=-profiling debug dynamic use-system-libffi -libffi-adjustors -find-ptr -v0
# cabal-configure (for _build/stage1/rts/setup-config)
# _build/stage1/rts/build/autogen/cabal_macros.h
| ContextData oracle: resolving data for 'rts' (Stage1, thr)...
# _build/stage1/rts/build/libHSrts-1.0.2.a
# _build/stage1/rts/build/include/ffitarget.h
# _build/stage1/rts/build/include/ffi.h
# cabal-autogen (for _build/stage1/rts/build/autogen/cabal_macros.h)
# ffitarget.h
# ffi.h
Error when running Shake build system:
at want, called at src/Main.hs:119:44 in main:Main
* Depends on: binary-dist
at apply1, called at src/Development/Shake/Internal/Rules/Rerun.hs:41:5 in shake-0.19.6-8286668a44703a51ff535fdb488bbcfda41ff46d5b093c47fded2bc0122481dd:Development.Shake.Internal.Rules.Rerun
* Depends on: binary-dist-dir
at need, called at src/Rules/BinaryDist.hs:130:9 in main:Rules.BinaryDist
* Depends on: _build/stage1/lib/package.conf.d/ghc-prim-0.8.0.conf
at apply1, called at src/Development/Shake/Internal/Rules/Oracle.hs:159:32 in shake-0.19.6-8286668a44703a51ff535fdb488bbcfda41ff46d5b093c47fded2bc0122481dd:Development.Shake.Internal.Rules.Oracle
* Depends on: OracleQ (ContextDataKey (Context {stage = Stage1, package = Package {pkgType = Library, pkgName = "ghc-prim", pkgPath = "libraries/ghc-prim"}, way = v}))
at need, called at src/Hadrian/Oracles/Cabal/Rules.hs:54:9 in main:Hadrian.Oracles.Cabal.Rules
* Depends on: _build/stage1/libraries/ghc-prim/setup-config
at need, called at src/Rules/Library.hs:165:18 in main:Rules.Library
* Depends on: _build/stage1/rts/build/include/ffi.h
at need, called at src/Hadrian/Utilities.hs:320:5 in main:Hadrian.Utilities
* Depends on: ffi.h
at error, called at src/Development/Shake/Internal/Rules/File.hs:179:58 in shake-0.19.6-8286668a44703a51ff535fdb488bbcfda41ff46d5b093c47fded2bc0122481dd:Development.Shake.Internal.Rules.File
* Raised the exception:
Error, file does not exist and no rule available:
ffi.h
Build failed.
Potential solutions:
- In hadrian, don't copy libffi headers when the build uses system libffi.
- In hadrian, add extra logic to find libffi headers when
--with-ffi-includes
is not used. - Fix
fp_find_libffi.m4
, setFFIIncludeDir
unconditionally. It's not straightforward how to auto-detect a header's absolute path in autoconf.