Merge pull request #43369 from dtzWill/experimental/ghc-musl-bootstrap

ghc: support musl-native!
This commit is contained in:
Will Dietz 2018-07-11 21:31:46 -05:00 committed by GitHub
commit fcfd66cea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
{ stdenv
, fetchurl, perl, gcc, llvm_39
, ncurses5, gmp, libiconv
, ncurses5, gmp, glibc, libiconv
}:
# Prebuilt only does native
@ -14,6 +14,13 @@ let
libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ "LD_LIBRARY_PATH";
glibcDynLinker = assert stdenv.isLinux;
if stdenv.hostPlatform.libc == "glibc" then
# Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
else
"${stdenv.lib.getLib glibc}/lib/ld-linux*";
in
stdenv.mkDerivation rec {
@ -95,7 +102,7 @@ stdenv.mkDerivation rec {
find . -type f -perm -0100 -exec patchelf \
--replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
--replace-needed libtinfo.so libtinfo.so.5 \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" {} \;
--interpreter ${glibcDynLinker} {} \;
paxmark m ./ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
@ -107,7 +114,8 @@ stdenv.mkDerivation rec {
configureFlags = [
"--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
"--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}";
] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
# Stripping combined with patchelf breaks the executables (they die
# with a segfault or the kernel even refuses the execve). (NIXPKGS-85)