snowleopard / hadrian

Hadrian: a new build system for the Glasgow Haskell Compiler. Now merged into the GHC tree!
https://gitlab.haskell.org/ghc/ghc/tree/master/hadrian
MIT License
208 stars 37 forks source link

Nix: /nix/store/.../bin/ld: cannot find -lgmp #615

Closed sgillespie closed 6 years ago

sgillespie commented 6 years ago

There appears to be a missing dependency on gmp in shell.nix:

/nix/store/j75dgadrff2d1fyc4fczmcgqkid2imdx-binutils-2.30/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
shakeArgsWith     0.000s    0%
Function shake    0.484s    0%
Database read     0.000s    0%
With database     0.002s    0%
Running rules  2199.161s   99%  =========================
Total          2199.647s  100%
Error when running Shake build system:
* _build/stage1/lib/bin/unlit
user error (Development.Shake.cmd, system command failed
Command: _build/stage0/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' -i -i_build/stage1/utils/unlit/build -i_build/stage1/utils/unlit/build/unlit/autogen -iutils/unlit/. -Iincludes -I_build/generated -I_build/stage1/utils/unlit/build -I/nix/store/70g2i2v6dqm5ss9p2m1jb8f2swsz46qh-gmp-6.1.2-dev/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage1/utils/unlit/build/unlit/autogen/cabal_macros.h -optc-fno-stack-protector -odir _build/stage1/utils/unlit/build -hidir _build/stage1/utils/unlit/build -stubdir _build/stage1/utils/unlit/build -no-auto-link-packages -no-hs-main -optl-lgmp -Wnoncanonical-monad-instances -optc-Werror=unused-but-set-variable -optc-Wno-error=inline _build/stage1/utils/unlit/build/c/unlit.o _build/stage1/utils/unlit/build/c/fs.o -o _build/stage1/lib/bin/unlit -O2 -H32m -XHaskell2010 -ghcversion-file=/home/sgillespie/dev/ghc-hadrian/_build/generated/ghcversion.h
Exit code: 1
Stderr:
/nix/store/j75dgadrff2d1fyc4fczmcgqkid2imdx-binutils-2.30/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
)
snowleopard commented 6 years ago

@sgillespie Thanks! Presumably, the solution is simple for those who know how to add a new dependency to shell.nix... Do you know Nix well enough to try to fix this?

alpmestan commented 6 years ago

@sgillespie Feel free to give a shot at https://github.com/alpmestan/ghc.nix. nix-shell ~/ghc.nix/ --run 'hadrian/build.sh -j' should just work (I use it with both the make build system and hadrian). Add -c if you have not run ./boot and ./configure.

Note: we may or may not later on replace the existing shell.nix in hadrian with this. It's quite recent but several GHC devs (like @bgamari and @mpickering) who are also Nix users use it on and off now, so it appears to be somewhat promising.

sgillespie commented 6 years ago

@snowleopard I will submit a patch shortly

sgillespie commented 6 years ago

Fixed by https://github.com/snowleopard/hadrian/pull/616