Hadrian build fails due to leftover files from previous build
Summary:
While trying to build the GHC JavaScript backend using Hadrian with the --bignum=native
option, the build process failed with an error indicating a missing dependency on the GMP library. @hsyl20 noticed (here) that the cause of this error was leftover files from a previous build, specifically ./_build/stage1/libraries/ghc-bignum/build/ghc-bignum.buildinfo
.
Steps to reproduce:
Run the following commands (I use ghc.nix
, nix-direnv
and zsh
, as described here):
./boot
./configure ${=CONFIGURE_ARGS}
emconfigure ./configure --target=javascript-unknown-ghcjs
hadrian/build -j12 --flavour=quick --bignum=native --docs=none
The error I encountered is as follows:
# cabal-configure (for _build/stage1/libraries/ghc-bignum/setup-config)
hadrian: Missing dependency on a foreign library:
* Missing (or bad) C library: gmp
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
library file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
ExitFailure 1
Build failed.
Expected behavior:
The build process should complete successfully with the --bignum=native
option, even when there are leftover files from a previous build.
Environment:
- GHC version used:
/nix/store/ms3xmj91p9sc3d8rgh1xj8ijx2dh9n5v-ghc-9.2.4-with-packages/bin/ghc
- Operating System: NixOS 23.05
- System Architecture:
x86_64-linux
Potential solution:
Hadrian could be updated to delete leftover files from previous builds, especially the ./_build/stage1/libraries/ghc-bignum/build/ghc-bignum.buildinfo
file, which is generated by cabal configure
for the ghc-bignum
package and is not currently tracked properly.