diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-03-08 18:29:08 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2004-03-08 18:29:08 +0000 |
commit | 946a2d4a4824d415e3c2c306dd7b4c1360946662 (patch) | |
tree | d6d51221bcfb90e9341c93fa04efd02bf387bd5a /pkgs | |
parent | ce50734cf067496ae50d1a6fd139fc03de283cbc (diff) |
* gcc-wrapper now filters out -L and -I flags referring to paths
outside the store (in pure builds).
svn path=/nixpkgs/trunk/; revision=817
Diffstat (limited to 'pkgs')
-rwxr-xr-x | pkgs/build-support/gcc-wrapper/builder.sh | 1 | ||||
-rw-r--r-- | pkgs/build-support/gcc-wrapper/default.nix | 1 | ||||
-rw-r--r-- | pkgs/build-support/gcc-wrapper/gcc-wrapper.sh | 39 | ||||
-rw-r--r-- | pkgs/build-support/gcc-wrapper/setup-hook.sh | 2 | ||||
-rw-r--r-- | pkgs/development/compilers/gcc-new/default.nix | 13 | ||||
-rwxr-xr-x | pkgs/development/libraries/glibc/builder.sh | 2 | ||||
-rw-r--r-- | pkgs/stdenv/generic/setup.sh | 9 | ||||
-rw-r--r-- | pkgs/system/all-packages.nix | 2 | ||||
-rw-r--r-- | pkgs/system/stdenvs.nix | 9 | ||||
-rwxr-xr-x | pkgs/test/simple/builder.sh | 5 |
10 files changed, 68 insertions, 15 deletions
diff --git a/pkgs/build-support/gcc-wrapper/builder.sh b/pkgs/build-support/gcc-wrapper/builder.sh index d3b1f433559c..92d187ab84d0 100755 --- a/pkgs/build-support/gcc-wrapper/builder.sh +++ b/pkgs/build-support/gcc-wrapper/builder.sh @@ -57,6 +57,7 @@ test -z "$isNative" && echo $glibc > $out/nix-support/orig-glibc sed \ -e "s^@isNative@^$isNative^g" \ + -e "s^@enforcePurity@^$enforcePurity^g" \ -e "s^@gcc@^$gcc^g" \ -e "s^@glibc@^$glibc^g" \ < $setupHook > $out/nix-support/setup-hook diff --git a/pkgs/build-support/gcc-wrapper/default.nix b/pkgs/build-support/gcc-wrapper/default.nix index da1896611645..11282e131dac 100644 --- a/pkgs/build-support/gcc-wrapper/default.nix +++ b/pkgs/build-support/gcc-wrapper/default.nix @@ -17,6 +17,7 @@ derivation { gccWrapper = ./gcc-wrapper.sh; ldWrapper = ./ld-wrapper.sh; inherit name stdenv isNative gcc glibc binutils; + enforcePurity = if isNative then false else gcc.noSysDirs; langC = if isNative then true else gcc.langC; langCC = if isNative then true else gcc.langCC; langF77 = if isNative then false else gcc.langF77; diff --git a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh index 59f38086f325..6cb3493f6bfc 100644 --- a/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh +++ b/pkgs/build-support/gcc-wrapper/gcc-wrapper.sh @@ -10,6 +10,7 @@ if test -z "$NIX_GLIBC_FLAGS_SET"; then NIX_LDFLAGS="@ldflags@ $NIX_LDFLAGS" fi + # Figure out if linker flags should be passed. GCC prints annoying # warnings when they are not needed. dontLink=0 @@ -33,6 +34,40 @@ else done fi + +# Optionally filter out paths not refering to the store. +skip () { + if test "$NIX_DEBUG" = "1"; then + echo "skipping impure path $1" >&2 + fi +} + +params=("$@") +if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then + rest=() + n=0 + while test $n -lt ${#params[*]}; do + p=${params[n]} + p2=${params[$((n+1))]} + if test "${p:0:3}" = "-L/" -a "${p:2:${#NIX_STORE}}" != "$NIX_STORE"; then + skip $p + elif test "$p" = "-L" -a "${p2:0:${#NIX_STORE}}" != "$NIX_STORE"; then + n=$((n + 1)); skip $p2 + elif test "${p:0:3}" = "-I/" -a "${p:2:${#NIX_STORE}}" != "$NIX_STORE"; then + skip $p + elif test "$p" = "-I" -a "${p2:0:${#NIX_STORE}}" != "$NIX_STORE"; then + n=$((n + 1)); skip $p2 + elif test "$p" = "-isystem" -a "${p2:0:${#NIX_STORE}}" != "$NIX_STORE"; then + n=$((n + 1)); skip $p2 + else + rest=("${rest[@]}" "$p") + fi + n=$((n + 1)) + done + params=("${rest[@]}") +fi + + # Add the flags for the C compiler proper. extra=($NIX_CFLAGS_COMPILE) @@ -58,7 +93,7 @@ fi # Optionally print debug info. if test "$NIX_DEBUG" = "1"; then echo "original flags to @gcc@:" >&2 - for i in "$@"; do + for i in "${params[@]}"; do echo " $i" >&2 done echo "extra flags to @gcc@:" >&2 @@ -71,4 +106,4 @@ if test -n "$NIX_GCC_WRAPPER_EXEC_HOOK"; then . "$NIX_GCC_WRAPPER_EXEC_HOOK" fi -exec @gcc@ "$@" ${extra[@]} +exec @gcc@ "${params[@]}" ${extra[@]} diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh index a4c52ba803d7..07c3b54b4730 100644 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-wrapper/setup-hook.sh @@ -13,3 +13,5 @@ envHooks=(${envHooks[@]} addCVars) if test -z "@isNative@"; then PATH=$PATH:@gcc@/bin:@glibc@/bin fi + +export NIX_ENFORCE_PURITY=@enforcePurity@ diff --git a/pkgs/development/compilers/gcc-new/default.nix b/pkgs/development/compilers/gcc-new/default.nix index 0d44cbe74b01..e2311a260237 100644 --- a/pkgs/development/compilers/gcc-new/default.nix +++ b/pkgs/development/compilers/gcc-new/default.nix @@ -1,19 +1,16 @@ -{ stdenv, fetchurl +{ stdenv, fetchurl, noSysDirs ? true , langC ? true, langCC ? true, langF77 ? false }: assert langC; derivation { - name = "gcc-3.3.2"; + name = "gcc-3.3.3"; system = stdenv.system; builder = ./builder.sh; src = fetchurl { -# url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-3.3.3/gcc-3.3.3.tar.bz2; -# md5 = "3c6cfd9fcd180481063b4058cf6faff2"; - url = ftp://ftp.nluug.nl/pub/gnu/gcc/gcc-3.3.2/gcc-3.3.2.tar.bz2; - md5 = "65999f654102f5438ac8562d13a6eced"; + url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-3.3.3/gcc-3.3.3.tar.bz2; + md5 = "3c6cfd9fcd180481063b4058cf6faff2"; }; - noSysDirs = stdenv.noSysDirs; - inherit stdenv langC langCC langF77; + inherit stdenv noSysDirs langC langCC langF77; } diff --git a/pkgs/development/libraries/glibc/builder.sh b/pkgs/development/libraries/glibc/builder.sh index 7503e73a171e..249ab0872ac6 100755 --- a/pkgs/development/libraries/glibc/builder.sh +++ b/pkgs/development/libraries/glibc/builder.sh @@ -15,7 +15,7 @@ LDFLAGS=-Wl,-S ../glibc-*/configure --prefix=$out --enable-add-ons --disable-pro make || exit 1 make install || exit 1 -make localedata/install-locales || exit 1 +#make localedata/install-locales || exit 1 strip -S $out/lib/*.a $out/lib/*.so $out/lib/gconv/*.so strip -s $out/bin/* $out/sbin/* $out/libexec/* diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index c163c04cb517..4530a1b1319a 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -21,6 +21,11 @@ param5=@param5@ . @preHook@ +if test -f @gcc@/nix-support/setup-hook; then + . @gcc@/nix-support/setup-hook +fi + + # Recursively find all build inputs. findInputs() { @@ -76,6 +81,10 @@ export NIX_STRIP_DEBUG=1 export NIX_CFLAGS_STRIP="-g0 -Wl,-s" +# Where is the store? This is required for purity checking. +export NIX_STORE=$(dirname $out)/ # !!! hack + + # Execute the post-hook. . @postHook@ diff --git a/pkgs/system/all-packages.nix b/pkgs/system/all-packages.nix index f1a0c917f718..666d0e672738 100644 --- a/pkgs/system/all-packages.nix +++ b/pkgs/system/all-packages.nix @@ -12,6 +12,6 @@ # Select the right instantiation. body = if system == "i686-linux" - then stdenvs.stdenvLinuxPkgs + then stdenvs.stdenvNativePkgs #stdenvs.stdenvLinuxPkgs else stdenvs.stdenvNixPkgs; } diff --git a/pkgs/system/stdenvs.nix b/pkgs/system/stdenvs.nix index 34804ad55d83..06a9fc50fedf 100644 --- a/pkgs/system/stdenvs.nix +++ b/pkgs/system/stdenvs.nix @@ -8,12 +8,19 @@ {system, allPackages}: rec { + # Trivial environment used for building other environments. + stdenvInitial = (import ../stdenv/initial) { + name = "stdenv-initial"; + inherit system; + }; + + # The native (i.e., impure) build environment. This one uses the # tools installed on the system outside of the Nix environment, # i.e., the stuff in /bin, /usr/bin, etc. This environment should # be used with care, since many Nix packages will not build properly # with it (e.g., because they require GNU Make). - stdenvNative = (import ../stdenv/native) {system = system;}; + stdenvNative = (import ../stdenv/native) {stdenv = stdenvInitial;}; stdenvNativePkgs = allPackages {system = system; stdenv = stdenvNative;}; diff --git a/pkgs/test/simple/builder.sh b/pkgs/test/simple/builder.sh index c155bdc36155..282fc520bd1f 100755 --- a/pkgs/test/simple/builder.sh +++ b/pkgs/test/simple/builder.sh @@ -4,7 +4,7 @@ export NIX_DEBUG=1 . $stdenv/setup -export NIX_CFLAGS_COMPILE="-v $NIX_CFLAGS_COMPILE" +#export NIX_CFLAGS_COMPILE="-v $NIX_CFLAGS_COMPILE" mkdir $out mkdir $out/bin @@ -19,7 +19,8 @@ int main(int argc, char * * argv) } EOF -gcc hello.c -o $out/bin/hello +#gcc -I/nix/store/foo -I /nix/store/foo -I/usr/lib -I /usr/lib hello.c -o $out/bin/hello +gcc -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello $out/bin/hello |