From aeffc007fb3829eab1e3e8f92a6e646f1be71d7a Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Wed, 21 Jun 2017 20:27:57 +0200 Subject: [PATCH 1/4] coreutils: fix tests depending on setuid/setgid bits (cherry picked from commit 6a850d2b11f22a22729b49f012fc26ff3c602f3f) --- pkgs/tools/misc/coreutils/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index d87976cbc5e..fdd18418083 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -31,6 +31,9 @@ stdenv.mkDerivation rec { sed '2i echo Skipping cp sparse test && exit 0' -i ./tests/cp/sparse.sh sed '2i echo Skipping rm deep-2 test && exit 0' -i ./tests/rm/deep-2.sh sed '2i echo Skipping du long-from-unreadable test && exit 0' -i ./tests/du/long-from-unreadable.sh + sed '2i echo Skipping chmod setgid test && exit 0' -i ./tests/chmod/setgid.sh + substituteInPlace ./tests/install/install-C.sh \ + --replace 'mode3=2755' 'mode3=1755' ''; outputs = [ "out" "info" ]; From d4595b38e90790a2b8ee01a7127889747ba05bb7 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Dec 2017 16:21:54 -0500 Subject: [PATCH 2/4] gcc: Modernize builder.sh for Cross Instead of `NIX_CC` vs `NIX_CC_CROSS` spagetti, unconditionally use `NIX_BUILD_CC` and `NIX_CC` in a consistent manner. --- .../development/compilers/gcc/4.5/default.nix | 9 +- .../development/compilers/gcc/4.8/default.nix | 12 +- .../development/compilers/gcc/4.9/default.nix | 12 +- pkgs/development/compilers/gcc/5/default.nix | 12 +- pkgs/development/compilers/gcc/6/default.nix | 12 +- pkgs/development/compilers/gcc/7/default.nix | 12 +- pkgs/development/compilers/gcc/builder.sh | 195 +++++++++--------- .../compilers/gcc/snapshot/default.nix | 12 +- 8 files changed, 134 insertions(+), 142 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index 5e19798c0fa..68c83a208da 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -274,6 +274,8 @@ stdenv.mkDerivation ({ ) ) } + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${ # Trick that should be taken out once we have a mips64el-linux not loongson2f if targetPlatform == hostPlatform && stdenv.system == "mips64el-linux" then "--with-arch=loongson2f" else ""} ${if langAda then " --enable-libada" else ""} @@ -325,11 +327,12 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; }; - + + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 69348d50d0a..17965406da0 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -338,11 +338,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -402,12 +399,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 5b5bd44322e..e41fc798efc 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -344,11 +344,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -408,12 +405,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index c9605416f4e..afdf8c2c928 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -359,11 +359,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -423,12 +420,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index fe308b77167..848d4cf6e6f 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -341,11 +341,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -405,12 +402,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 3ca6e470c2f..96d2d5f2efc 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -342,11 +342,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -406,12 +403,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, targetPlatform != hostPlatform - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index ee56425f00b..12097f8ff95 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -1,8 +1,17 @@ source $stdenv/setup -export NIX_FIXINC_DUMMY=$NIX_BUILD_TOP/dummy -mkdir $NIX_FIXINC_DUMMY +oldOpts="$(shopt -po nounset)" || true +set -euo pipefail + + +if test -n "${NIX_CC_CROSS-}"; then + export NIX_CC="$NIX_CC_CROSS" +fi + + +export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" +mkdir "$NIX_FIXINC_DUMMY" if test "$staticCompiler" = "1"; then @@ -20,134 +29,126 @@ echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'" if test "$noSysDirs" = "1"; then - if test -e $NIX_CC/nix-support/orig-libc; then + declare \ + EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \ + EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS - # Figure out what extra flags to pass to the gcc compilers - # being generated to make sure that they use our glibc. - extraFlags="$(cat $NIX_CC/nix-support/libc-cflags)" - extraLDFlags="$(cat $NIX_CC/nix-support/libc-ldflags) $(cat $NIX_CC/nix-support/libc-ldflags-before || true)" + for pre in 'BUILD_' ''; do + curCC="NIX_${pre}CC" + curFIXINC="NIX_${pre}FIXINC_DUMMY" - # Use *real* header files, otherwise a limits.h is generated - # that does not include Glibc's limits.h (notably missing - # SSIZE_MAX, which breaks the build). - export NIX_FIXINC_DUMMY=$libc_dev/include + declare -a extraFlags=() extraLDFlags=() + if [[ -e "${!curCC}/nix-support/orig-libc" ]]; then + # Figure out what extra flags to pass to the gcc compilers being + # generated to make sure that they use our glibc. + extraFlags=($(cat "${!curCC}/nix-support/libc-cflags")) + extraLDFlags=($(cat "${!curCC}/nix-support/libc-ldflags") $(cat "${!curCC}/nix-support/libc-ldflags-before" || true)) - # The path to the Glibc binaries such as `crti.o'. - glibc_libdir="$(cat $NIX_CC/nix-support/orig-libc)/lib" + # The path to the Glibc binaries such as `crti.o'. + glibc_libdir="$(cat "${!curCC}/nix-support/orig-libc")/lib" + glibc_devdir="$(cat "${!curCC}/nix-support/orig-libc-dev")" - else - # Hack: support impure environments. - extraFlags="-isystem /usr/include" - extraLDFlags="-L/usr/lib64 -L/usr/lib" - glibc_libdir="/usr/lib" - export NIX_FIXINC_DUMMY=/usr/include - fi + # Use *real* header files, otherwise a limits.h is generated that + # does not include Glibc's limits.h (notably missing SSIZE_MAX, + # which breaks the build). + declare NIX_${pre}FIXINC_DUMMY="$glibc_devdir/include" + else + # Hack: support impure environments. + extraFlags=("-isystem" "/usr/include") + extraLDFlags=("-L/usr/lib64" "-L/usr/lib") + glibc_libdir="/usr/lib" + declare NIX_${pre}FIXINC_DUMMY=/usr/include + fi - extraFlags="-I$NIX_FIXINC_DUMMY $extraFlags" - extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" + extraFlags=("-I${!curFIXINC}" + "${extraFlags[@]}") + extraLDFlags=("-L$glibc_libdir" "-rpath" "$glibc_libdir" + "${extraLDFlags[@]}") - # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, - # make sure to explictly add them so that files compiled with the - # bootstrap compiler are optimized and (optionally) contain - # debugging information (info "(gccinstall) Building"). - if test -n "$dontStrip"; then - extraFlags="-O2 -g $extraFlags" - else - # Don't pass `-g' at all; this saves space while building. - extraFlags="-O2 $extraFlags" - fi + # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make + # sure to explictly add them so that files compiled with the bootstrap + # compiler are optimized and (optionally) contain debugging information + # (info "(gccinstall) Building"). + if test -n "${dontStrip-}"; then + extraFlags=("-O2" "-g" "${extraFlags[@]}") + else + # Don't pass `-g' at all; this saves space while building. + extraFlags=("-O2" "${extraFlags[@]}") + fi - EXTRA_FLAGS="$extraFlags" - for i in $extraLDFlags; do - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,$i" + declare EXTRA_${pre}FLAGS="${extraFlags[*]}" + for i in "${extraLDFlags[@]}"; do + declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" + done done - if test -n "$targetConfig"; then - # Cross-compiling, we need gcc not to read ./specs in order to build - # the g++ compiler (after the specs for the cross-gcc are created). - # Having LIBRARY_PATH= makes gcc read the specs from ., and the build + if test -n "${targetConfig-}"; then + # Cross-compiling, we need gcc not to read ./specs in order to build the + # g++ compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build # breaks. Having this variable comes from the default.nix code to bring # gcj in. unset LIBRARY_PATH unset CPATH else - if test -z "$NIX_CC_CROSS"; then - EXTRA_TARGET_CFLAGS="$EXTRA_FLAGS" - EXTRA_TARGET_CXXFLAGS="$EXTRA_FLAGS" - EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" - else - # This the case of cross-building the gcc. - # We need special flags for the target, different than those of the build - # Assertion: - test -e $NIX_CC_CROSS/nix-support/orig-libc - - # Figure out what extra flags to pass to the gcc compilers - # being generated to make sure that they use our glibc. - extraFlags="$(cat $NIX_CC_CROSS/nix-support/libc-cflags)" - extraLDFlags="$(cat $NIX_CC_CROSS/nix-support/libc-ldflags) $(cat $NIX_CC_CROSS/nix-support/libc-ldflags-before)" - - # The path to the Glibc binaries such as `crti.o'. - glibc_dir="$(cat $NIX_CC_CROSS/nix-support/orig-libc)" - glibc_libdir="$glibc_dir/lib" - glibc_devdir="$(cat $NIX_CC_CROSS/nix-support/orig-libc-dev)" - configureFlags="$configureFlags --with-native-system-header-dir=$glibc_devdir/include" - - # Use *real* header files, otherwise a limits.h is generated - # that does not include Glibc's limits.h (notably missing - # SSIZE_MAX, which breaks the build). - NIX_FIXINC_DUMMY_CROSS="$glibc_devdir/include" - - extraFlags="-I$NIX_FIXINC_DUMMY_CROSS $extraFlags" - extraLDFlags="-L$glibc_libdir -rpath $glibc_libdir $extraLDFlags" - - EXTRA_TARGET_CFLAGS="$extraFlags" - for i in $extraLDFlags; do - EXTRA_TARGET_LDFLAGS="$EXTRA_TARGET_LDFLAGS -Wl,$i" - done - fi + # host = target, so the flags are the same + EXTRA_TARGET_FLAGS="$EXTRA_FLAGS" + EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" fi # CFLAGS_FOR_TARGET are needed for the libstdc++ configure script to find # the startfiles. # FLAGS_FOR_TARGET are needed for the target libraries to receive the -Bxxx # for the startfiles. - makeFlagsArray+=( \ - NATIVE_SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - SYSTEM_HEADER_DIR="$NIX_FIXINC_DUMMY" \ - CFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - CXXFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - CFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ - CXXFLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ - FLAGS_FOR_TARGET="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ - LDFLAGS_FOR_BUILD="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - LDFLAGS_FOR_TARGET="$EXTRA_TARGET_LDFLAGS $EXTRA_TARGET_LDFLAGS" \ - ) + makeFlagsArray+=( + "BUILD_SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "SYSTEM_HEADER_DIR=$NIX_BUILD_FIXINC_DUMMY" + "NATIVE_SYSTEM_HEADER_DIR=$NIX_FIXINC_DUMMY" - if test -z "$targetConfig"; then - makeFlagsArray+=( \ - BOOT_CFLAGS="$EXTRA_FLAGS $EXTRA_LDFLAGS" \ - BOOT_LDFLAGS="$EXTRA_TARGET_CFLAGS $EXTRA_TARGET_LDFLAGS" \ - ) + "LDFLAGS_FOR_BUILD=$EXTRA_BUILD_LDFLAGS" + #"LDFLAGS=$EXTRA_LDFLAGS" + "LDFLAGS_FOR_TARGET=$EXTRA_TARGET_LDFLAGS" + + "CFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "CXXFLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + "FLAGS_FOR_BUILD=$EXTRA_BUILD_FLAGS $EXTRA_BUILD_LDFLAGS" + + # It seems there is a bug in GCC 5 + #"CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + #"CXXFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + + "CFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "CXXFLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + "FLAGS_FOR_TARGET=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) + + if test -z "${targetConfig-}"; then + makeFlagsArray+=( + "BOOT_CFLAGS=$EXTRA_FLAGS $EXTRA_LDFLAGS" + "BOOT_LDFLAGS=$EXTRA_TARGET_FLAGS $EXTRA_TARGET_LDFLAGS" + ) fi - if test -n "$targetConfig" -a "$crossStageStatic" == 1; then + if test -n "${targetConfig-}" -a "$crossStageStatic" == 1; then # We don't want the gcc build to assume there will be a libc providing # limits.h in this stagae - makeFlagsArray+=( \ - LIMITS_H_TEST=false \ - ) + makeFlagsArray+=( + 'LIMITS_H_TEST=false' + ) else - makeFlagsArray+=( \ - LIMITS_H_TEST=true \ - ) + makeFlagsArray+=( + 'LIMITS_H_TEST=true' + ) fi fi -if test -n "$targetConfig"; then +if test -n "${targetConfig-}"; then # The host strip will destroy some important details of the objects dontStrip=1 fi +eval "$oldOpts" + providedPreConfigure="$preConfigure"; preConfigure() { if test -n "$newlibSrc"; then diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index ec7e234607e..8212c1c85ba 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -342,11 +342,8 @@ stdenv.mkDerivation ({ ) ) } - ${if targetPlatform == hostPlatform - then if hostPlatform.isDarwin - then " --with-native-system-header-dir=${darwin.usr-include}" - else " --with-native-system-header-dir=${getDev stdenv.cc.libc}/include" - else ""} + ${optionalString (!(crossMingw && crossStageStatic)) + "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -406,12 +403,13 @@ stdenv.mkDerivation ({ STRIP_FOR_TARGET = "${targetPlatform.config}-strip"; CC_FOR_TARGET = "${targetPlatform.config}-gcc"; CXX_FOR_TARGET = "${targetPlatform.config}-g++"; - # If we are making a cross compiler, cross != null - NIX_CC_CROSS = if targetPlatform == hostPlatform then "${stdenv.ccCross}" else ""; + dontStrip = true; buildFlags = ""; }; + NIX_BUILD_CC = stdenv.cc; + NIX_CC_CROSS = stdenv.ccCross or null; # Needed for the cross compilation to work AR = "ar"; From d96cf0f46c2df4c83f6c518bca9869b789b07172 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 2 Dec 2017 12:26:49 -0500 Subject: [PATCH 3/4] gcc: Handle `CPATH` and `LIBRARY_PATH` purely in Nix --- .../development/compilers/gcc/4.5/default.nix | 67 ++++++++++--------- .../development/compilers/gcc/4.8/default.nix | 64 +++++++++--------- .../development/compilers/gcc/4.9/default.nix | 64 +++++++++--------- pkgs/development/compilers/gcc/5/default.nix | 64 +++++++++--------- pkgs/development/compilers/gcc/6/default.nix | 66 +++++++++--------- pkgs/development/compilers/gcc/7/default.nix | 66 +++++++++--------- pkgs/development/compilers/gcc/builder.sh | 18 ++--- .../compilers/gcc/snapshot/default.nix | 66 +++++++++--------- 8 files changed, 240 insertions(+), 235 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index 68c83a208da..c4dae5c8b66 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -339,18 +339,21 @@ stdenv.mkDerivation ({ LD = "ld"; CC = "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -360,41 +363,39 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. - ++ optionals (libcCross != null && - hasAttr "propagatedBuildInputs" libcCross) - libcCross.propagatedBuildInputs); + ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${libcCross.dev}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${libcCross.dev}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langAda langFortran langVhdl enableMultilib version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 17965406da0..15529bd554a 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -413,18 +413,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -435,39 +438,38 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) - libcCross.propagatedBuildInputs); + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${libcCross.dev}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${libcCross.dev}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index e41fc798efc..6ece3abd935 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -419,18 +419,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -441,39 +444,38 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) - libcCross.propagatedBuildInputs); + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${libcCross.dev}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${libcCross.dev}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index afdf8c2c928..f6242573e67 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -434,18 +434,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optionals langJava [ boehmgc ] ++ optionals javaAwtGtk xlibs @@ -456,39 +459,38 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) - libcCross.propagatedBuildInputs); + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${getDev libcCross}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 848d4cf6e6f..324fb3e0c1a 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -416,18 +416,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -437,40 +440,39 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. - ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs") - libcCross.propagatedBuildInputs); + ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${getDev libcCross}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 96d2d5f2efc..c8d54308c95 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -417,18 +417,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -438,40 +441,39 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. - ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs") - libcCross.propagatedBuildInputs); + ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${getDev libcCross}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 12097f8ff95..3bc1cb49eec 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -22,10 +22,10 @@ fi # GCC interprets empty paths as ".", which we don't want. -if test -z "$CPATH"; then unset CPATH; fi -if test -z "$LIBRARY_PATH"; then unset LIBRARY_PATH; fi -echo "\$CPATH is \`$CPATH'" -echo "\$LIBRARY_PATH is \`$LIBRARY_PATH'" +if test -z "${CPATH-}"; then unset CPATH; fi +if test -z "${LIBRARY_PATH-}"; then unset LIBRARY_PATH; fi +echo "\$CPATH is \`${CPATH-}'" +echo "\$LIBRARY_PATH is \`${LIBRARY_PATH-}'" if test "$noSysDirs" = "1"; then @@ -82,15 +82,7 @@ if test "$noSysDirs" = "1"; then done done - if test -n "${targetConfig-}"; then - # Cross-compiling, we need gcc not to read ./specs in order to build the - # g++ compiler (after the specs for the cross-gcc are created). Having - # LIBRARY_PATH= makes gcc read the specs from ., and the build - # breaks. Having this variable comes from the default.nix code to bring - # gcj in. - unset LIBRARY_PATH - unset CPATH - else + if test -z "${targetConfig-}"; then # host = target, so the flags are the same EXTRA_TARGET_FLAGS="$EXTRA_FLAGS" EXTRA_TARGET_LDFLAGS="$EXTRA_LDFLAGS" diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index 8212c1c85ba..fd34f414f96 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -417,18 +417,21 @@ stdenv.mkDerivation ({ # http://gcc.gnu.org/install/specific.html#x86-64-x-solaris210 CC = if stdenv.system == "x86_64-solaris" then "gcc -m64" else "gcc"; - # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find - # the library headers and binaries, regarless of the language being - # compiled. - - # Note: When building the Java AWT GTK+ peer, the build system doesn't - # honor `--with-gmp' et al., e.g., when building - # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just - # add them to $CPATH and $LIBRARY_PATH in this case. + # Setting $CPATH and $LIBRARY_PATH to make sure both `gcc' and `xgcc' find the + # library headers and binaries, regarless of the language being compiled. + # + # Note: When building the Java AWT GTK+ peer, the build system doesn't honor + # `--with-gmp' et al., e.g., when building + # `libjava/classpath/native/jni/java-math/gnu_java_math_GMP.c', so we just add + # them to $CPATH and $LIBRARY_PATH in this case. # # Likewise, the LTO code doesn't find zlib. + # + # Cross-compiling, we need gcc not to read ./specs in order to build the g++ + # compiler (after the specs for the cross-gcc are created). Having + # LIBRARY_PATH= makes gcc read the specs from ., and the build breaks. - CPATH = makeSearchPathOutput "dev" "include" ([] + CPATH = optionals (targetPlatform == hostPlatform) (makeSearchPathOutput "dev" "include" ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs @@ -438,40 +441,39 @@ stdenv.mkDerivation ({ # On GNU/Hurd glibc refers to Mach & Hurd # headers. - ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs") - libcCross.propagatedBuildInputs); + ++ optionals (libcCross != null && libcCross ? "propagatedBuildInputs" ) + libcCross.propagatedBuildInputs + )); - LIBRARY_PATH = makeLibraryPath ([] + LIBRARY_PATH = optionals (targetPlatform == hostPlatform) (makeLibraryPath ([] ++ optional (zlib != null) zlib ++ optional langJava boehmgc ++ optionals javaAwtGtk xlibs ++ optionals javaAwtGtk [ gmp mpfr ] - ++ optional (libpthread != null) libpthread); + ++ optional (libpthread != null) libpthread) + ); - EXTRA_TARGET_CFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-idirafter ${getDev libcCross}/include" - ] - ++ optionals (! crossStageStatic) [ - "-B${libcCross.out}/lib" - ] - else null; + EXTRA_TARGET_FLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-idirafter ${getDev libcCross}/include" + ] ++ optionals (! crossStageStatic) [ + "-B${libcCross.out}/lib" + ]); - EXTRA_TARGET_LDFLAGS = - if targetPlatform != hostPlatform && libcCross != null then [ - "-Wl,-L${libcCross.out}/lib" - ] - ++ (if crossStageStatic then [ + EXTRA_TARGET_LDFLAGS = optionals + (targetPlatform != hostPlatform && libcCross != null) + ([ + "-Wl,-L${libcCross.out}/lib" + ] ++ (if crossStageStatic then [ "-B${libcCross.out}/lib" ] else [ "-Wl,-rpath,${libcCross.out}/lib" "-Wl,-rpath-link,${libcCross.out}/lib" - ]) - ++ optionals (libpthreadCross != null) [ - "-L${libpthreadCross}/lib" - "-Wl,${libpthreadCross.TARGET_LDFLAGS}" - ] - else null; + ]) ++ optionals (libpthreadCross != null) [ + "-L${libpthreadCross}/lib" + "-Wl,${libpthreadCross.TARGET_LDFLAGS}" + ]); passthru = { inherit langC langCC langObjC langObjCpp langAda langFortran langVhdl langGo version; isGNU = true; }; From 51948eab9415fde1825dea5c7d31b99b2e1a0fdb Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 1 Dec 2017 17:13:58 -0500 Subject: [PATCH 4/4] gcc: Fix after merge - NIX_CC_CROSS is now completely gone! - NIX_CC is defined reliably, so no manual def needed - stdenv.ccCross -> stdenv.cc, also removing need for "or" fallback --- pkgs/development/compilers/gcc/4.5/default.nix | 6 +++--- pkgs/development/compilers/gcc/4.8/default.nix | 6 +++--- pkgs/development/compilers/gcc/4.9/default.nix | 6 +++--- pkgs/development/compilers/gcc/5/default.nix | 6 ++---- pkgs/development/compilers/gcc/6/default.nix | 6 +++--- pkgs/development/compilers/gcc/7/default.nix | 6 +++--- pkgs/development/compilers/gcc/builder.sh | 5 ----- pkgs/development/compilers/gcc/snapshot/default.nix | 6 +++--- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index c4dae5c8b66..b84a4464888 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -25,6 +25,7 @@ , libpthread ? null, libpthreadCross ? null # required for GNU/Hurd , stripped ? true , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -275,7 +276,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${ # Trick that should be taken out once we have a mips64el-linux not loongson2f if targetPlatform == hostPlatform && stdenv.system == "mips64el-linux" then "--with-arch=loongson2f" else ""} ${if langAda then " --enable-libada" else ""} @@ -331,8 +332,7 @@ stdenv.mkDerivation ({ dontStrip = true; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 15529bd554a..86c4198be23 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -33,6 +33,7 @@ , gnused ? null , darwin ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -339,7 +340,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -404,8 +405,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index 6ece3abd935..2aa3f340df7 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -33,6 +33,7 @@ , gnused ? null , darwin ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -345,7 +346,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -410,8 +411,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index 5d08f785da3..146b1acbb9f 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -295,7 +295,6 @@ stdenv.mkDerivation ({ ++ (optionals langJava [ boehmgc zip unzip ]) ++ (optionals javaAwtGtk ([ gtk2 libart_lgpl ] ++ xlibs)) ++ (optionals (targetPlatform != hostPlatform) [binutils]) - ++ (optionals (buildPlatform != hostPlatform) [buildPackages.stdenv.cc]) ++ (optionals langAda [gnatboot]) ++ (optionals langVhdl [gnat]) @@ -362,7 +361,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -431,8 +430,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index 324fb3e0c1a..581ee32af3e 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -35,6 +35,7 @@ , cloog # unused; just for compat with gcc4, as we override the parameter on some places , darwin ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -342,7 +343,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -407,8 +408,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index c8d54308c95..d70214e4114 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -36,6 +36,7 @@ , darwin ? null , flex ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -343,7 +344,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -408,8 +409,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar"; diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 3bc1cb49eec..d21755d7b1d 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -5,11 +5,6 @@ oldOpts="$(shopt -po nounset)" || true set -euo pipefail -if test -n "${NIX_CC_CROSS-}"; then - export NIX_CC="$NIX_CC_CROSS" -fi - - export NIX_FIXINC_DUMMY="$NIX_BUILD_TOP/dummy" mkdir "$NIX_FIXINC_DUMMY" diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index fd34f414f96..78891e2c987 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -36,6 +36,7 @@ , darwin ? null , flex ? null , buildPlatform, hostPlatform, targetPlatform +, buildPackages }: assert langJava -> zip != null && unzip != null @@ -343,7 +344,7 @@ stdenv.mkDerivation ({ ) } ${optionalString (!(crossMingw && crossStageStatic)) - "--with-native-system-header-dir=${getDev (stdenv.ccCross or stdenv.cc).libc}/include"} + "--with-native-system-header-dir=${getDev stdenv.cc.libc}/include"} ${if langAda then " --enable-libada" else ""} ${if targetPlatform == hostPlatform && targetPlatform.isi686 then "--with-arch=i686" else ""} ${if targetPlatform != hostPlatform then crossConfigureFlags else ""} @@ -408,8 +409,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; - NIX_BUILD_CC = stdenv.cc; - NIX_CC_CROSS = stdenv.ccCross or null; + NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work AR = "ar";