From 4a1d311c4941839b0d1abf14df2c50cbc5434009 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 10 Jul 2018 22:06:23 -0500 Subject: [PATCH 1/3] ghc821-binary: use glibc on musl These prebuilt binaries need to be used with glibc, it doesn't matter what we're using otherwise. This may seem a bit strange but has the huge advantage of not needing to create/host/download musl-specific variants, and instead continue to use the official ones from upstream. --- pkgs/development/compilers/ghc/8.2.1-binary.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index 9bd7dfcb9fc14ab..4a3c817e9fcb960 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -1,6 +1,6 @@ { stdenv , fetchurl, perl, gcc, llvm_39 -, ncurses5, gmp, libiconv +, ncurses5, gmp, glibc, libiconv }: # Prebuilt only does native @@ -14,6 +14,12 @@ let libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY" + "LD_LIBRARY_PATH"; + glibcDynLinker = assert stdenv.isLinux; + if stdenv.hostPlatform.libc == "glibc" then + stdenv.cc.bintools.dynamicLinker + else + "${stdenv.lib.getLib glibc}/lib/ld-linux*"; + in stdenv.mkDerivation rec { @@ -95,7 +101,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 From b4c91a3e1ab5b9065a317b6387abdaa093e5bf11 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 11 Jul 2018 06:26:21 -0500 Subject: [PATCH 2/3] ghc821-binary: disable ld override w/musl Fixes conftest failure that I believe ends up using the wrong dynamic linker. --- pkgs/development/compilers/ghc/8.2.1-binary.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index 4a3c817e9fcb960..1eeea19b6b0a7ad 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -113,7 +113,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) From e065779af185b07566b9bbc4d2fc2ea70fdf3856 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 11 Jul 2018 08:26:36 -0500 Subject: [PATCH 3/3] ghc821-binary: avoid mass-rebuild by using old dynamic linker string --- pkgs/development/compilers/ghc/8.2.1-binary.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index 1eeea19b6b0a7ad..bfb9c4cd6164827 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -16,7 +16,8 @@ let glibcDynLinker = assert stdenv.isLinux; if stdenv.hostPlatform.libc == "glibc" then - stdenv.cc.bintools.dynamicLinker + # 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*";