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
This commit is contained in:
Matthew Bauer 2016-06-19 23:05:08 -05:00
parent 20a8349d62
commit f05bb6d23f
6 changed files with 21 additions and 54 deletions

View File

@ -170,7 +170,7 @@ let version = "4.6.4";
"-stage-final"; "-stage-final";
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; 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 in

View File

@ -70,7 +70,8 @@ let version = "4.8.5";
# The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its # The GNAT Makefiles did not pay attention to CFLAGS_FOR_TARGET for its
# target libraries and tools. # target libraries and tools.
++ optional langAda ../gnat-cflags.patch ++ optional langAda ../gnat-cflags.patch
++ optional langFortran ../gfortran-driving.patch; ++ optional langFortran ../gfortran-driving.patch
++ optional stdenv.isDarwin ../gfortran-darwin-NXConstStr.patch;
javaEcj = fetchurl { javaEcj = fetchurl {
# The `$(top_srcdir)/ecj.jar' file is automatically picked up at # 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"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; 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 in
@ -304,15 +305,6 @@ stdenv.mkDerivation ({
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" 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 CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_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; dontDisableStatic = true;

View File

@ -199,7 +199,7 @@ let version = "4.9.3";
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
bootstrap = cross == null; bootstrap = cross == null && !stdenv.isDarwin;
in in
@ -307,15 +307,6 @@ stdenv.mkDerivation ({
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" 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 CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_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) '' + stdenv.lib.optionalString (langJava || langGo) ''
export lib=$out; export lib=$out;

View File

@ -198,7 +198,7 @@ let version = "5.3.0";
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
bootstrap = cross == null; bootstrap = cross == null && !stdenv.isDarwin;
in in
@ -306,15 +306,6 @@ stdenv.mkDerivation ({
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" 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 CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_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; dontDisableStatic = true;

View File

@ -198,7 +198,7 @@ let version = "6.1.0";
stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final"; stageNameAddon = if crossStageStatic then "-stage-static" else "-stage-final";
crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else ""; crossNameAddon = if cross != null then "-${cross.config}" + stageNameAddon else "";
bootstrap = cross == null; bootstrap = cross == null && !stdenv.isDarwin;
in in
@ -306,15 +306,6 @@ stdenv.mkDerivation ({
export LDFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $LDFLAGS_FOR_TARGET" 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 CXXFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CXXFLAGS_FOR_TARGET"
export CFLAGS_FOR_TARGET="-Wl,-rpath,$prefix/lib/amd64 $CFLAGS_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; dontDisableStatic = true;

View File

@ -229,19 +229,21 @@ postInstall() {
# More dependencies with the previous gcc or some libs (gccbug stores the build command line) # More dependencies with the previous gcc or some libs (gccbug stores the build command line)
rm -rf $out/bin/gccbug rm -rf $out/bin/gccbug
# Take out the bootstrap-tools from the rpath, as it's not needed at all having $out if type "patchelf"; then
for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do # Take out the bootstrap-tools from the rpath, as it's not needed at all having $out
PREV_RPATH=`patchelf --print-rpath "$i"` for i in $(find "$out"/libexec/gcc/*/*/* -type f -a \! -name '*.la'); do
NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'` PREV_RPATH=`patchelf --print-rpath "$i"`
patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK NEW_RPATH=`echo "$PREV_RPATH" | sed 's,:[^:]*bootstrap-tools/lib,,g'`
done patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
done
# For some reason the libs retain RPATH to $out # For some reason the libs retain RPATH to $out
for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do for i in "$lib"/lib/{libtsan,libasan,libubsan}.so.*.*.*; do
PREV_RPATH=`patchelf --print-rpath "$i"` PREV_RPATH=`patchelf --print-rpath "$i"`
NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"` NEW_RPATH=`echo "$PREV_RPATH" | sed "s,:${out}[^:]*,,g"`
patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK patchelf --set-rpath "$NEW_RPATH" "$i" && echo OK
done done
fi
# Get rid of some "fixed" header files # Get rid of some "fixed" header files
rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux} rm -rfv $out/lib/gcc/*/*/include-fixed/{root,linux}