gcj: fix build on Darwin

Partially addresses https://github.com/NixOS/nixpkgs/issues/29715.
This commit is contained in:
Alyssa Ross 2018-11-15 21:02:42 +00:00
parent 4abc6ff9e8
commit b9b83748f3
No known key found for this signature in database
GPG key ID: C4844408C0657052
2 changed files with 24 additions and 12 deletions

View file

@ -23,7 +23,14 @@ fixDarwinDylibNames() {
for fn in "$@"; do for fn in "$@"; do
if [ -L "$fn" ]; then continue; fi if [ -L "$fn" ]; then continue; fi
echo "$fn: fixing dylib" echo "$fn: fixing dylib"
install_name_tool -id "$fn" "${flags[@]}" "$fn" int_out=$(install_name_tool -id "$fn" "${flags[@]}" "$fn" 2>&1)
result=$?
if [ "$result" -ne 0 ] &&
! grep "shared library stub file and can't be changed" <<< "$out"
then
echo "$int_out" >&2
exit "$result"
fi
done done
} }

View file

@ -180,18 +180,23 @@ stdenv.mkDerivation ({
hardeningDisable = [ "format" "pie" ]; hardeningDisable = [ "format" "pie" ];
# This should kill all the stdinc frameworks that gcc and friends like to prePatch =
# insert into default search paths. (stdenv.lib.optionalString (langJava || langGo) ''
prePatch = stdenv.lib.optionalString hostPlatform.isDarwin '' export lib=$out
substituteInPlace gcc/config/darwin-c.c \ '')
--replace 'if (stdinc)' 'if (0)'
substituteInPlace libgcc/config/t-slibgcc-darwin \ # This should kill all the stdinc frameworks that gcc and friends like to
--replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)" # insert into default search paths.
+ stdenv.lib.optionalString hostPlatform.isDarwin ''
substituteInPlace gcc/config/darwin-c.c \
--replace 'if (stdinc)' 'if (0)'
substituteInPlace libgfortran/configure \ substituteInPlace libgcc/config/t-slibgcc-darwin \
--replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname" --replace "-install_name @shlib_slibdir@/\$(SHLIB_INSTALL_NAME)" "-install_name $lib/lib/\$(SHLIB_INSTALL_NAME)"
'';
substituteInPlace libgfortran/configure \
--replace "-install_name \\\$rpath/\\\$soname" "-install_name $lib/lib/\\\$soname"
'';
postPatch = postPatch =
if targetPlatform != hostPlatform || stdenv.cc.libc != null then if targetPlatform != hostPlatform || stdenv.cc.libc != null then
@ -447,7 +452,7 @@ stdenv.mkDerivation ({
// optionalAttrs (enableMultilib) { dontMoveLib64 = true; } // optionalAttrs (enableMultilib) { dontMoveLib64 = true; }
// optionalAttrs (langJava) { // optionalAttrs (langJava && !stdenv.hostPlatform.isDarwin) {
postFixup = '' postFixup = ''
target="$(echo "$out/libexec/gcc"/*/*/ecj*)" target="$(echo "$out/libexec/gcc"/*/*/ecj*)"
patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target" patchelf --set-rpath "$(patchelf --print-rpath "$target"):$out/lib" "$target"