From 12e0672d8848852677c6c77a63e2c793ad7a266b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 9 Dec 2017 14:19:02 -0500 Subject: [PATCH] gcc: Adjust builder.sh to find some things in bintools-wrapper instead --- .../development/compilers/gcc/4.5/default.nix | 1 + .../development/compilers/gcc/4.8/default.nix | 1 + .../development/compilers/gcc/4.9/default.nix | 1 + pkgs/development/compilers/gcc/5/default.nix | 1 + pkgs/development/compilers/gcc/6/default.nix | 1 + pkgs/development/compilers/gcc/7/default.nix | 1 + pkgs/development/compilers/gcc/builder.sh | 53 ++++++++++++------- .../compilers/gcc/snapshot/default.nix | 1 + 8 files changed, 41 insertions(+), 19 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.5/default.nix b/pkgs/development/compilers/gcc/4.5/default.nix index b41d22f4f53..b4ae867d585 100644 --- a/pkgs/development/compilers/gcc/4.5/default.nix +++ b/pkgs/development/compilers/gcc/4.5/default.nix @@ -356,6 +356,7 @@ stdenv.mkDerivation ({ dontStrip = true; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 8713c174d5a..4efac1b26c3 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -444,6 +444,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/4.9/default.nix b/pkgs/development/compilers/gcc/4.9/default.nix index c338f9c641e..fb4218a0ede 100644 --- a/pkgs/development/compilers/gcc/4.9/default.nix +++ b/pkgs/development/compilers/gcc/4.9/default.nix @@ -442,6 +442,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/5/default.nix b/pkgs/development/compilers/gcc/5/default.nix index 552e827ec36..b4399ef72f1 100644 --- a/pkgs/development/compilers/gcc/5/default.nix +++ b/pkgs/development/compilers/gcc/5/default.nix @@ -451,6 +451,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/6/default.nix b/pkgs/development/compilers/gcc/6/default.nix index fbc49002606..d923092168a 100644 --- a/pkgs/development/compilers/gcc/6/default.nix +++ b/pkgs/development/compilers/gcc/6/default.nix @@ -452,6 +452,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/7/default.nix b/pkgs/development/compilers/gcc/7/default.nix index 032a20271ee..c9daf813e6f 100644 --- a/pkgs/development/compilers/gcc/7/default.nix +++ b/pkgs/development/compilers/gcc/7/default.nix @@ -446,6 +446,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh index 0765daee453..1796c83385e 100644 --- a/pkgs/development/compilers/gcc/builder.sh +++ b/pkgs/development/compilers/gcc/builder.sh @@ -28,37 +28,55 @@ if test "$noSysDirs" = "1"; then EXTRA_BUILD_FLAGS EXTRA_FLAGS EXTRA_TARGET_FLAGS \ EXTRA_BUILD_LDFLAGS EXTRA_TARGET_LDFLAGS + # Extract flags from Bintools Wrappers + for pre in 'BUILD_' ''; do + curBintools="NIX_${pre}BINTOOLS" + + declare -a extraLDFlags=() + if [[ -e "${!curBintools}/nix-support/orig-libc" ]]; then + # Figure out what extra flags when linking to pass to the gcc + # compilers being generated to make sure that they use our libc. + extraLDFlags=($(< "${!curBintools}/nix-support/libc-ldflags") $(< "${!curBintools}/nix-support/libc-ldflags-before" || true)) + + # The path to the Libc binaries such as `crti.o'. + libc_libdir="$(< "${!curBintools}/nix-support/orig-libc")/lib" + else + # Hack: support impure environments. + extraLDFlags=("-L/usr/lib64" "-L/usr/lib") + libc_libdir="/usr/lib" + fi + extraLDFlags=("-L$libc_libdir" "-rpath" "$libc_libdir" + "${extraLDFlags[@]}") + for i in "${extraLDFlags[@]}"; do + declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" + done + done + + # Extract flags from CC Wrappers for pre in 'BUILD_' ''; do curCC="NIX_${pre}CC" curFIXINC="NIX_${pre}FIXINC_DUMMY" - declare -a extraFlags=() extraLDFlags=() + declare -a extraFlags=() 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)) + # Figure out what extra compiling flags to pass to the gcc compilers + # being generated to make sure that they use our libc. + extraFlags=($(< "${!curCC}/nix-support/libc-cflags")) - # 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")" + # The path to the Libc headers + libc_devdir="$(< "${!curCC}/nix-support/orig-libc-dev")" # Use *real* header files, otherwise a limits.h is generated that - # does not include Glibc's limits.h (notably missing SSIZE_MAX, + # does not include Libc's limits.h (notably missing SSIZE_MAX, # which breaks the build). - declare NIX_${pre}FIXINC_DUMMY="$glibc_devdir/include" + declare NIX_${pre}FIXINC_DUMMY="$libc_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${!curFIXINC}" - "${extraFlags[@]}") - extraLDFlags=("-L$glibc_libdir" "-rpath" "$glibc_libdir" - "${extraLDFlags[@]}") + extraFlags=("-I${!curFIXINC}" "${extraFlags[@]}") # BOOT_CFLAGS defaults to `-g -O2'; since we override it below, make # sure to explictly add them so that files compiled with the bootstrap @@ -72,9 +90,6 @@ if test "$noSysDirs" = "1"; then fi declare EXTRA_${pre}FLAGS="${extraFlags[*]}" - for i in "${extraLDFlags[@]}"; do - declare EXTRA_${pre}LDFLAGS+=" -Wl,$i" - done done if test -z "${targetConfig-}"; then diff --git a/pkgs/development/compilers/gcc/snapshot/default.nix b/pkgs/development/compilers/gcc/snapshot/default.nix index f2f8eeb09a5..9d1bdc08133 100644 --- a/pkgs/development/compilers/gcc/snapshot/default.nix +++ b/pkgs/development/compilers/gcc/snapshot/default.nix @@ -433,6 +433,7 @@ stdenv.mkDerivation ({ buildFlags = ""; }; + NIX_BUILD_BINTOOLS = buildPackages.stdenv.cc.bintools; NIX_BUILD_CC = buildPackages.stdenv.cc; # Needed for the cross compilation to work