From 9a10434f4d1265dd93ff7ae78bc8f97418efc7ff Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 17 Mar 2019 04:53:19 -0500 Subject: [PATCH 1/2] ghc{822,863}Binary: fix to work w/musl again, __strdup -> strdup --- pkgs/development/compilers/ghc/8.2.2-binary.nix | 9 +++++++++ pkgs/development/compilers/ghc/8.6.3-binary.nix | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/pkgs/development/compilers/ghc/8.2.2-binary.nix b/pkgs/development/compilers/ghc/8.2.2-binary.nix index 678245d3e437..d9c44cb47e79 100644 --- a/pkgs/development/compilers/ghc/8.2.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.2-binary.nix @@ -107,6 +107,15 @@ stdenv.mkDerivation rec { sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + '' + + # We're kludging a glibc bindist into working with non-glibc... + # Here we patch up the use of `__strdup` (part of glibc binary ABI) + # to instead use `strdup` since musl doesn't provide __strdup + # (`__strdup` is defined to be an alias of `strdup` anyway[1]). + # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html + # Use objcopy magic to make the change: + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + find ./ghc-${version}/rts -name "libHSrts*.a" -exec objcopy --redefine-sym __strdup=strdup {} \; ''; configurePlatforms = [ ]; diff --git a/pkgs/development/compilers/ghc/8.6.3-binary.nix b/pkgs/development/compilers/ghc/8.6.3-binary.nix index cde67183ef49..907eded2094a 100644 --- a/pkgs/development/compilers/ghc/8.6.3-binary.nix +++ b/pkgs/development/compilers/ghc/8.6.3-binary.nix @@ -99,6 +99,15 @@ stdenv.mkDerivation rec { sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2 + '' + + # We're kludging a glibc bindist into working with non-glibc... + # Here we patch up the use of `__strdup` (part of glibc binary ABI) + # to instead use `strdup` since musl doesn't provide __strdup + # (`__strdup` is defined to be an alias of `strdup` anyway[1]). + # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html + # Use objcopy magic to make the change: + stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' + find ./ghc-${version}/rts -name "libHSrts*.a" -exec objcopy --redefine-sym __strdup=strdup {} \; ''; configurePlatforms = [ ]; From 93e3eecdb3c98ba2c7afc59b38f98a2827e5c47d Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 18 Mar 2019 01:55:01 -0500 Subject: [PATCH 2/2] ghc*Binary: use $OBJCOPY when invoking objcopy (touchup musl fix) --- pkgs/development/compilers/ghc/8.2.2-binary.nix | 2 +- pkgs/development/compilers/ghc/8.6.3-binary.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.2.2-binary.nix b/pkgs/development/compilers/ghc/8.2.2-binary.nix index d9c44cb47e79..af98e9a311d5 100644 --- a/pkgs/development/compilers/ghc/8.2.2-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.2-binary.nix @@ -115,7 +115,7 @@ stdenv.mkDerivation rec { # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html # Use objcopy magic to make the change: stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' - find ./ghc-${version}/rts -name "libHSrts*.a" -exec objcopy --redefine-sym __strdup=strdup {} \; + find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \; ''; configurePlatforms = [ ]; diff --git a/pkgs/development/compilers/ghc/8.6.3-binary.nix b/pkgs/development/compilers/ghc/8.6.3-binary.nix index 907eded2094a..7e845da5b648 100644 --- a/pkgs/development/compilers/ghc/8.6.3-binary.nix +++ b/pkgs/development/compilers/ghc/8.6.3-binary.nix @@ -107,7 +107,7 @@ stdenv.mkDerivation rec { # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html # Use objcopy magic to make the change: stdenv.lib.optionalString stdenv.hostPlatform.isMusl '' - find ./ghc-${version}/rts -name "libHSrts*.a" -exec objcopy --redefine-sym __strdup=strdup {} \; + find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \; ''; configurePlatforms = [ ];