From f05bb6d23f2575374c8399a626aed36002302ff7 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Sun, 19 Jun 2016 23:05:08 -0500 Subject: [PATCH] gcc: fix darwin building - disable bootstrap builds on Darwin - remove xcrun calls - check if patchelf is available before using - apply darwin patch for gcc4.9 - fixes #16047 - fixes #14812 --- .../development/compilers/gcc/4.6/default.nix | 2 +- .../development/compilers/gcc/4.8/default.nix | 14 +++------- .../development/compilers/gcc/4.9/default.nix | 11 +------- pkgs/development/compilers/gcc/5/default.nix | 11 +------- pkgs/development/compilers/gcc/6/default.nix | 11 +------- pkgs/development/compilers/gcc/builder.sh | 26 ++++++++++--------- 6 files changed, 21 insertions(+), 54 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 7003f4335c8..f912b4400f0 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -170,7 +170,7 @@ let version = "4.6.4"; "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; - bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips; + bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips && !stdenv.isDarwin; in diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 6810b52574c..3af123c677d 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -70,7 +70,8 @@ let version = "4.8.5"; # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its # target libraries and tools. ++ optional langAda ../gnat-cflags.patch - ++ optional langFortran ../gfortran-driving.patch; + ++ optional langFortran ../gfortran-driving.patch + ++ optional stdenv.isDarwin ../gfortran-darwin-NXConstStr.patch; javaEcj = fetchurl { # The `$(top_srcdir)/ecj.jar' file is automatically picked up at @@ -197,7 +198,7 @@ let version = "4.8.5"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; - bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips; + bootstrap = cross == null && !stdenv.isArm && !stdenv.isMips && !stdenv.isDarwin; in @@ -304,15 +305,6 @@ stdenv.mkDerivation ({ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" - '' + stdenv.lib.optionalString stdenv.isDarwin '' - if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then - configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include) - makeFlagsArray+=( \ - CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \ - CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - ) - fi ''; dontDisableStatic = true; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 195a7b03eed..c0c3b77a190 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -199,7 +199,7 @@ let version = "4.9.3"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; - bootstrap = cross == null; + bootstrap = cross == null && !stdenv.isDarwin; in @@ -307,15 +307,6 @@ stdenv.mkDerivation ({ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" - '' + stdenv.lib.optionalString stdenv.isDarwin '' - if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then - configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include) - makeFlagsArray+=( \ - CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \ - CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - ) - fi '' + stdenv.lib.optionalString (langJava || langGo) '' export lib=$out; diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index 9e0220ffc72..0e80a0da8e8 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -198,7 +198,7 @@ let version = "5.3.0"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; - bootstrap = cross == null; + bootstrap = cross == null && !stdenv.isDarwin; in @@ -306,15 +306,6 @@ stdenv.mkDerivation ({ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" - '' + stdenv.lib.optionalString stdenv.isDarwin '' - if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then - configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include) - makeFlagsArray+=( \ - CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \ - CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - ) - fi ''; dontDisableStatic = true; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 6ca0f2f59f4..d7bcf8a2626 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -198,7 +198,7 @@ let version = "6.1.0"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; - bootstrap = cross == null; + bootstrap = cross == null && !stdenv.isDarwin; in @@ -306,15 +306,6 @@ stdenv.mkDerivation ({ export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" export CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET" export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_FOR_TARGET" - '' + stdenv.lib.optionalString stdenv.isDarwin '' - if SDKROOT=$(/usr/bin/xcrun --show-sdk-path); then - configureFlagsArray+=(--with-native-system-header-dir=$SDKROOT/usr/include) - makeFlagsArray+=( \ - CFLAGS_FOR_BUILD=-F$SDKROOT/System/Library/Frameworks \ - CFLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - FLAGS_FOR_TARGET=-F$SDKROOT/System/Library/Frameworks \ - ) - fi ''; dontDisableStatic = true; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 22107e72ef7..037ceae3d56 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -229,19 +229,21 @@ postInstall() { # More dependencies with the previous gcc or some libs (gccbug stores the build command line) rm -rf $out/bin/gccbug - # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out - for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do - PREV_RPATH=`patchelf --print-rpath "$i"` - NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'` - patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK - done + if type "patchelf"; then + # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out + for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done - # For some reason the libs retain RPATH to $out - for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do - PREV_RPATH=`patchelf --print-rpath "$i"` - NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"` - patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK - done + # For some reason the libs retain RPATH to $out + for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do + PREV_RPATH=`patchelf --print-rpath "$i"` + NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"` + patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK + done + fi # Get rid of some "fixed" header files rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}