diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index 3e9104a82fb..7c5cd686272 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -237,10 +237,16 @@ stdenv.mkDerivation ({ # This should kill all the stdinc frameworks that gcc and friends like to # insert into default search paths. - prePatch = if stdenv.isDarwin then '' + prePatch = stdenv.lib.optionalString stdenv.isDarwin '' substituteInPlace gcc/config/darwin-c.c \ --replace 'if (stdinc)' 'if (0)' - '' else null; + + substituteInPlace libgcc/config/t-slibgcc-darwin \ + --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 = if (stdenv.isGNU diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index de3e9ba3ef5..ee56425f00b 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -212,6 +212,7 @@ postInstall() { # Move runtime libraries to $lib. moveToOutput "lib/lib*.so*" "$lib" moveToOutput "lib/lib*.la" "$lib" + moveToOutput "lib/lib*.dylib" "$lib" moveToOutput "share/gcc-*/python" "$lib" for i in "$lib"/lib/*.{la,py}; do @@ -221,6 +222,7 @@ postInstall() { if [ -n "$enableMultilib" ]; then moveToOutput "lib64/lib*.so*" "$lib" moveToOutput "lib64/lib*.la" "$lib" + moveToOutput "lib64/lib*.dylib" "$lib" for i in "$lib"/lib64/*.{la,py}; do substituteInPlace "$i" --replace "$out" "$lib" @@ -251,6 +253,16 @@ postInstall() { done fi + if type "install_name_tool"; then + for i in "$lib"/lib/*.*.dylib; do + install_name_tool -id "$i" "$i" || true + for old_path in $(otool -L "$i" | grep "$out" | awk '{print $1}'); do + new_path=`echo "$old_path" | sed "s,$out,$lib,"` + install_name_tool -change "$old_path" "$new_path" "$i" || true + done + done + fi + # Get rid of some "fixed" header files rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}