From aad382248f0d5a4be002c005e37d2d58625d3b17 Mon Sep 17 00:00:00 2001 From: Armijn Hemel Date: Mon, 22 Nov 2004 16:36:27 +0000 Subject: add modified gcc-wrapper svn path=/nixpkgs/branches/nixos-pkgs/; revision=1793 --- pkgs/build-support/gcc-wrapper/builder.sh | 8 +++++++- pkgs/build-support/gcc-wrapper/default.nix | 2 +- pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 22 +++++++++++++++------- pkgs/build-support/gcc-wrapper/ld-wrapper.sh | 4 +++- 4 files changed, 26 insertions(+), 10 deletions(-) (limited to 'pkgs/build-support/gcc-wrapper') diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh index c0c0c53a7a6..d48f57e159c 100644 --- a/pkgs/build-support/gcc-wrapper/builder.sh +++ b/pkgs/build-support/gcc-wrapper/builder.sh @@ -9,8 +9,12 @@ if test -z "$nativeGlibc"; then # against the crt1.o from our own glibc, rather than the one in # /usr/lib. The real solution is of course to prevent those paths # from being used by gcc in the first place. + # The dynamic linker is passed in `ldflagsBefore' to allow + # explicit overrides of the dynamic linker by callers to gcc/ld + # (the *last* value counts, so ours should come first). cflagsCompile="$cflagsCompile -B$glibc/lib -isystem $glibc/include" - ldflags="$ldflags -L$glibc/lib -dynamic-linker $glibc/lib/ld-linux.so.2" + ldflags="$ldflags -L$glibc/lib" + ldflagsBefore="-dynamic-linker $glibc/lib/ld-linux.so.2" fi if test -n "$nativeTools"; then @@ -57,6 +61,7 @@ ln -s g77 $out/bin/f77 sed \ -e "s^@out@^$out^g" \ -e "s^@ldflags@^$ldflags^g" \ + -e "s^@ldflagsBefore@^$ldflagsBefore^g" \ -e "s^@ld@^$ldPath/ld^g" \ -e "s^@shell@^$shell^g" \ < $ldWrapper > $out/bin/ld @@ -71,6 +76,7 @@ cat > $out/nix-support/add-flags < nativePrefix != ""; assert !nativeTools -> gcc != null && binutils != null; -assert !nativeGlibc -> glibc != null; +#assert !nativeGlibc -> glibc != null; stdenv.mkDerivation { builder = ./builder.sh; diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh index 149d6e2fcbc..fa2abe07650 100644 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh @@ -63,24 +63,28 @@ fi # Add the flags for the C compiler proper. -extra=($NIX_CFLAGS_COMPILE) +extraAfter=($NIX_CFLAGS_COMPILE) +extraBefore=() if test "$dontLink" != "1"; then # Add the flags that should only be passed to the compiler when # linking. - extra=(${extra[@]} $NIX_CFLAGS_LINK) + extraAfter=(${extraAfter[@]} $NIX_CFLAGS_LINK) # Add the flags that should be passed to the linker (and prevent # `ld-wrapper' from adding NIX_LDFLAGS again). + for i in $NIX_LDFLAGS_BEFORE; do + extraBefore=(${extraBefore[@]} "-Wl,$i") + done for i in $NIX_LDFLAGS; do - extra=(${extra[@]} "-Wl,$i") + extraAfter=(${extraAfter[@]} "-Wl,$i") done export NIX_LDFLAGS_SET=1 if test "$NIX_STRIP_DEBUG" = "1"; then # Add executable-stripping flags. - extra=(${extra[@]} $NIX_CFLAGS_STRIP) + extraAfter=(${extraAfter[@]} $NIX_CFLAGS_STRIP) fi fi @@ -90,8 +94,12 @@ if test "$NIX_DEBUG" = "1"; then for i in "${params[@]}"; do echo " $i" >&2 done - echo "extra flags to @gcc@:" >&2 - for i in ${extra[@]}; do + echo "extraBefore flags to @gcc@:" >&2 + for i in ${extraBefore[@]}; do + echo " $i" >&2 + done + echo "extraAfter flags to @gcc@:" >&2 + for i in ${extraAfter[@]}; do echo " $i" >&2 done fi @@ -100,4 +108,4 @@ if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then . "$NIX_GCC_WRAPPER_EXEC_HOOK" fi -exec @gcc@ "${params[@]}" ${extra[@]} +exec @gcc@ ${extraBefore[@]} "${params[@]}" ${extraAfter[@]} diff --git a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh index d90b290e007..362392c154f 100644 --- a/pkgs/build-support/gcc-wrapper/ld-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/ld-wrapper.sh @@ -42,9 +42,11 @@ fi extra=() +extraBefore=() if test -z "$NIX_LDFLAGS_SET"; then extra=(${extra[@]} $NIX_LDFLAGS) + extraBefore=(${extraBefore[@]} $NIX_LDFLAGS_BEFORE) fi @@ -141,4 +143,4 @@ if test -n "$NIX_LD_WRAPPER_EXEC_HOOK"; then . "$NIX_LD_WRAPPER_EXEC_HOOK" fi -exec @ld@ "${params[@]}" ${extra[@]} +exec @ld@ ${extraBefore[@]} "${params[@]}" ${extra[@]} -- cgit 1.4.1