Merge pull request #57784 from dtzWill/fix/ghc-musl-strdup

ghc{822,863}Binary: fix to work w/musl again, __strdup -> strdup
This commit is contained in:
Will Dietz 2019-03-18 12:44:08 -05:00 committed by GitHub
commit 3ff71fcc8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View file

@ -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:-objcopy} --redefine-sym __strdup=strdup {} \;
'';
configurePlatforms = [ ];

View file

@ -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:-objcopy} --redefine-sym __strdup=strdup {} \;
'';
configurePlatforms = [ ];