From a1b3ae0c8121b932beeceb46bef816bdb2a9f180 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 9 Mar 2004 17:16:02 +0000 Subject: * stdenv-nix-linux should more-or-less work again now. svn path=/nixpkgs/trunk/; revision=826 --- pkgs/development/compilers/gcc-new/builder.sh | 65 ------------------------ pkgs/development/compilers/gcc-new/default.nix | 20 -------- pkgs/development/compilers/gcc/builder.sh | 65 ++++++++++++++++++++++++ pkgs/development/compilers/gcc/default.nix | 20 ++++++++ pkgs/development/libraries/glibc/builder.sh | 12 ++--- pkgs/development/tools/misc/binutils/builder.sh | 20 ++++---- pkgs/development/tools/misc/binutils/default.nix | 7 +-- pkgs/stdenv/generic/default.nix | 2 +- pkgs/stdenv/generic/setup.sh | 20 ++++++-- pkgs/stdenv/native/default.nix | 5 +- pkgs/stdenv/native/posthook.sh | 0 pkgs/stdenv/nix-linux/boot.nix | 25 +++++---- pkgs/stdenv/nix-linux/default.nix | 24 +++++---- pkgs/stdenv/nix-linux/posthook.sh | 0 pkgs/stdenv/nix-linux/prehook-boot.sh | 17 ------- pkgs/stdenv/nix-linux/prehook.sh | 17 +------ pkgs/stdenv/nix/posthook.sh | 0 pkgs/system/all-packages-generic.nix | 4 +- pkgs/system/stdenvs.nix | 4 +- pkgs/test/simple/builder.sh | 4 +- pkgs/test/simple/default.nix | 8 +-- 21 files changed, 164 insertions(+), 175 deletions(-) delete mode 100755 pkgs/development/compilers/gcc-new/builder.sh delete mode 100644 pkgs/development/compilers/gcc-new/default.nix create mode 100755 pkgs/development/compilers/gcc/builder.sh create mode 100644 pkgs/development/compilers/gcc/default.nix delete mode 100644 pkgs/stdenv/native/posthook.sh delete mode 100644 pkgs/stdenv/nix-linux/posthook.sh delete mode 100644 pkgs/stdenv/nix/posthook.sh diff --git a/pkgs/development/compilers/gcc-new/builder.sh b/pkgs/development/compilers/gcc-new/builder.sh deleted file mode 100755 index ce772d07a78..00000000000 --- a/pkgs/development/compilers/gcc-new/builder.sh +++ /dev/null @@ -1,65 +0,0 @@ -#! /bin/sh -e - -buildinputs="$binutils" -. $stdenv/setup - -tar xvfj $src - -if test "$enforcePurity" = "1"; then - # Disable the standard include directories. - cd gcc-* - cat >> ./gcc/cppdefault.h < $mf.tmp - mv $mf.tmp $mf - - mf=gcc/Makefile - sed \ - -e "s^X_CFLAGS =\(.*\)^X_CFLAGS = \1 $extraflags^" \ - < $mf > $mf.tmp - mv $mf.tmp $mf - - # Patch gcc/Makefile to prevent fixinc.sh from "fixing" system header files - # from /usr/include. - mf=gcc/Makefile - sed \ - -e "s^NATIVE_SYSTEM_HEADER_DIR =\(.*\)^NATIVE_SYSTEM_HEADER_DIR = /fixinc-disabled^" \ - < $mf > $mf.tmp - mv $mf.tmp $mf -fi - -# Build and install. -make bootstrap -make install - -find $out -name "*.a" -exec strip -S {} \; diff --git a/pkgs/development/compilers/gcc-new/default.nix b/pkgs/development/compilers/gcc-new/default.nix deleted file mode 100644 index 9e79b21cd7a..00000000000 --- a/pkgs/development/compilers/gcc-new/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ stdenv, fetchurl, enforcePurity ? true -, langC ? true, langCC ? true, langF77 ? false -}: - -assert langC; - -derivation { - name = "gcc-3.3.2"; - system = stdenv.system; - builder = ./builder.sh; - src = fetchurl { - url = ftp://ftp.nluug.nl/pub/gnu/gcc/gcc-3.3.2/gcc-3.3.2.tar.bz2; - md5 = "65999f654102f5438ac8562d13a6eced"; - }; -# src = fetchurl { -# url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-3.3.3/gcc-3.3.3.tar.bz2; -# md5 = "3c6cfd9fcd180481063b4058cf6faff2"; -# }; - inherit stdenv enforcePurity langC langCC langF77; -} diff --git a/pkgs/development/compilers/gcc/builder.sh b/pkgs/development/compilers/gcc/builder.sh new file mode 100755 index 00000000000..ce772d07a78 --- /dev/null +++ b/pkgs/development/compilers/gcc/builder.sh @@ -0,0 +1,65 @@ +#! /bin/sh -e + +buildinputs="$binutils" +. $stdenv/setup + +tar xvfj $src + +if test "$enforcePurity" = "1"; then + # Disable the standard include directories. + cd gcc-* + cat >> ./gcc/cppdefault.h < $mf.tmp + mv $mf.tmp $mf + + mf=gcc/Makefile + sed \ + -e "s^X_CFLAGS =\(.*\)^X_CFLAGS = \1 $extraflags^" \ + < $mf > $mf.tmp + mv $mf.tmp $mf + + # Patch gcc/Makefile to prevent fixinc.sh from "fixing" system header files + # from /usr/include. + mf=gcc/Makefile + sed \ + -e "s^NATIVE_SYSTEM_HEADER_DIR =\(.*\)^NATIVE_SYSTEM_HEADER_DIR = /fixinc-disabled^" \ + < $mf > $mf.tmp + mv $mf.tmp $mf +fi + +# Build and install. +make bootstrap +make install + +find $out -name "*.a" -exec strip -S {} \; diff --git a/pkgs/development/compilers/gcc/default.nix b/pkgs/development/compilers/gcc/default.nix new file mode 100644 index 00000000000..9e79b21cd7a --- /dev/null +++ b/pkgs/development/compilers/gcc/default.nix @@ -0,0 +1,20 @@ +{ stdenv, fetchurl, enforcePurity ? true +, langC ? true, langCC ? true, langF77 ? false +}: + +assert langC; + +derivation { + name = "gcc-3.3.2"; + system = stdenv.system; + builder = ./builder.sh; + src = fetchurl { + url = ftp://ftp.nluug.nl/pub/gnu/gcc/gcc-3.3.2/gcc-3.3.2.tar.bz2; + md5 = "65999f654102f5438ac8562d13a6eced"; + }; +# src = fetchurl { +# url = ftp://ftp.nluug.nl/mirror/languages/gcc/releases/gcc-3.3.3/gcc-3.3.3.tar.bz2; +# md5 = "3c6cfd9fcd180481063b4058cf6faff2"; +# }; + inherit stdenv enforcePurity langC langCC langF77; +} diff --git a/pkgs/development/libraries/glibc/builder.sh b/pkgs/development/libraries/glibc/builder.sh index e3842a81c1d..b671d269cbf 100755 --- a/pkgs/development/libraries/glibc/builder.sh +++ b/pkgs/development/libraries/glibc/builder.sh @@ -5,22 +5,22 @@ export NIX_NO_SELF_RPATH=1 . $stdenv/setup tar xvfj $glibcSrc -(cd glibc-* && tar xvfj $linuxthreadsSrc) +(cd glibc-* && tar xvfj $linuxthreadsSrc) || false -(cd glibc-* && patch -p1 < $vaargsPatch) +(cd glibc-* && patch -p1 < $vaargsPatch) || false mkdir build cd build -LDFLAGS=-Wl,-S ../glibc-*/configure --prefix=$out --enable-add-ons --disable-profile +../glibc-*/configure --prefix=$out --enable-add-ons --disable-profile make make install -#make localedata/install-locales +make localedata/install-locales strip -S $out/lib/*.a $out/lib/*.so $out/lib/gconv/*.so || true strip -s $out/bin/* $out/sbin/* $out/libexec/* || true -ln -sf /etc/ld.so.cache $out/etc/ld.so.cache +rm $out/etc/ld.so.cache -(cd $out/include && ln -s $kernelHeaders/include/* .) +(cd $out/include && ln -s $kernelHeaders/include/* .) || false exit 0 diff --git a/pkgs/development/tools/misc/binutils/builder.sh b/pkgs/development/tools/misc/binutils/builder.sh index 7782ea08988..f76eb534c55 100755 --- a/pkgs/development/tools/misc/binutils/builder.sh +++ b/pkgs/development/tools/misc/binutils/builder.sh @@ -1,17 +1,17 @@ -#! /bin/sh +#! /bin/sh -e -. $stdenv/setup || exit 1 +. $stdenv/setup -tar xvfj $src || exit 1 -cd binutils-* || exit 1 +tar xvfj $src +cd binutils-* # Clear the default library search path. -if test "$noSysDirs" == "1"; then - echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt || exit 1 +if test "$enforcePurity" = "1"; then + echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt fi -./configure --prefix=$out || exit 1 -make || exit 1 -make install || exit 1 +./configure --prefix=$out +make +make install -strip -S $out/lib/*.a || exit 1 +strip -S $out/lib/*.a diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 07d6b416a54..3f027d90fcc 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -1,4 +1,6 @@ -{stdenv, fetchurl}: derivation { +{stdenv, fetchurl, enforcePurity ? true}: + +derivation { name = "binutils-2.14"; system = stdenv.system; builder = ./builder.sh; @@ -6,6 +8,5 @@ url = ftp://ftp.nluug.nl/pub/gnu/binutils/binutils-2.14.tar.bz2; md5 = "2da8def15d28af3ec6af0982709ae90a"; }; - stdenv = stdenv; - noSysDirs = stdenv.noSysDirs; + inherit stdenv enforcePurity; } diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index c816e588808..9c877252e2b 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -1,4 +1,4 @@ -{ stdenv, name, preHook, postHook, initialPath, gcc +{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? "" }: diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index c1b2ef99236..259417afaa3 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -1,9 +1,11 @@ set -e +test -z $NIX_GCC && NIX_GCC=@gcc@ + # Set up the initial path. PATH= -for i in @gcc@ @initialPath@; do +for i in $NIX_GCC @initialPath@; do PATH=$PATH${PATH:+:}$i/bin done @@ -18,12 +20,18 @@ param2=@param2@ param3=@param3@ param4=@param4@ param5=@param5@ -. @preHook@ +if test -n "@preHook@"; then + . @preHook@ +fi + + +# Check that the pre-hook initialised SHELL. +if test -z "$SHELL"; then echo "SHELL not set"; exit 1; fi # Hack: run gcc's setup hook. -if test -f @gcc@/nix-support/setup-hook; then - . @gcc@/nix-support/setup-hook +if test -f $NIX_GCC/nix-support/setup-hook; then + . $NIX_GCC/nix-support/setup-hook fi @@ -93,7 +101,9 @@ export TZ=UTC # Execute the post-hook. -. @postHook@ +if test -n "@postHook@"; then + . @postHook@ +fi PATH=$_PATH${_PATH:+:}$PATH if test "$NIX_DEBUG" = "1"; then diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index cf5a1da1987..2fd6b670c39 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -3,15 +3,14 @@ (import ../generic) { name = "stdenv-native"; preHook = ./prehook.sh; - postHook = ./posthook.sh; initialPath = "/usr/local /usr /"; inherit stdenv; gcc = (import ../../build-support/gcc-wrapper) { - inherit stdenv; name = "gcc-native"; isNative = true; - gcc = "/usr"; + nativePrefix = "/usr"; + inherit stdenv; }; } diff --git a/pkgs/stdenv/native/posthook.sh b/pkgs/stdenv/native/posthook.sh deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/pkgs/stdenv/nix-linux/boot.nix b/pkgs/stdenv/nix-linux/boot.nix index c42b3f33302..cc5ab2122e8 100644 --- a/pkgs/stdenv/nix-linux/boot.nix +++ b/pkgs/stdenv/nix-linux/boot.nix @@ -1,13 +1,16 @@ -{system, glibc}: (import ../generic) { - name = "stdenv-linux-boot"; - system = system; - prehook = ./prehook-boot.sh; - posthook = ./posthook.sh; +{stdenv, glibc}: + +(import ../generic) { + name = "stdenv-nix-linux-boot"; + preHook = ./prehook-boot.sh; initialPath = "/usr/local /usr /"; - param1 = ""; - param2 = ""; - param3 = ""; - param4 = glibc; - param5 = ""; - noSysDirs = true; + + inherit stdenv; + + gcc = (import ../../build-support/gcc-wrapper) { + name = "gcc-native"; + isNative = true; + nativePrefix = "/usr"; + inherit stdenv glibc; + }; } diff --git a/pkgs/stdenv/nix-linux/default.nix b/pkgs/stdenv/nix-linux/default.nix index b0898826b5d..51893975748 100644 --- a/pkgs/stdenv/nix-linux/default.nix +++ b/pkgs/stdenv/nix-linux/default.nix @@ -1,13 +1,19 @@ -{bootStdenv, pkgs, glibc}: (import ../generic) { +{stdenv, glibc, pkgs}: + +(import ../generic) { name = "stdenv-nix-linux"; - system = bootStdenv.system; - prehook = ./prehook.sh; - posthook = ./posthook.sh; + preHook = ./prehook.sh; initialPath = (import ../nix/path.nix) {pkgs = pkgs;}; + + inherit stdenv; + + gcc = (import ../../build-support/gcc-wrapper) { + name = "gcc-native"; + isNative = false; + gcc = pkgs.gcc; + binutils = pkgs.binutils; + inherit stdenv glibc; + }; + param1 = pkgs.bash; - param2 = pkgs.gcc; - param3 = pkgs.binutils; - param4 = glibc; - param5 = ""; - noSysDirs = true; } diff --git a/pkgs/stdenv/nix-linux/posthook.sh b/pkgs/stdenv/nix-linux/posthook.sh deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/pkgs/stdenv/nix-linux/prehook-boot.sh b/pkgs/stdenv/nix-linux/prehook-boot.sh index 193f232c337..af1ba16ccbe 100644 --- a/pkgs/stdenv/nix-linux/prehook-boot.sh +++ b/pkgs/stdenv/nix-linux/prehook-boot.sh @@ -1,18 +1 @@ export SHELL=/bin/sh - -export NIX_CC=/usr/bin/gcc -export NIX_CXX=/usr/bin/g++ -export NIX_LD=/usr/bin/ld - -# The "-B$param4/lib" is a quick hack to force gcc to link 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. -# !!! -B should really be in NIX_CFLAGS_LINK, but ld-wrapper also uses -# that one (incorrectly?). -export NIX_CFLAGS_COMPILE="-B$param4/lib -isystem $param4/include $NIX_CFLAGS_COMPILE" -export NIX_CFLAGS_LINK="-L$param4/lib $NIX_CFLAGS_LINK" -export NIX_LDFLAGS="-dynamic-linker $param4/lib/ld-linux.so.2 -rpath $param4/lib $NIX_LDFLAGS" - -export NIX_LIBC_INCLUDES="$param4/include" -export NIX_LIBC_LIBS="$param4/lib" diff --git a/pkgs/stdenv/nix-linux/prehook.sh b/pkgs/stdenv/nix-linux/prehook.sh index 087b245401c..0e0bada4fcb 100644 --- a/pkgs/stdenv/nix-linux/prehook.sh +++ b/pkgs/stdenv/nix-linux/prehook.sh @@ -1,18 +1,3 @@ export SHELL=$param1 -export NIX_CC=$param2/bin/gcc -export NIX_CXX=$param2/bin/g++ -export NIX_LD=$param3/bin/ld - -# The "-B$param4/lib" is a quick hack to force gcc to link 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. -# !!! -B should really be in NIX_CFLAGS_LINK, but ld-wrapper also uses -# that one (incorrectly?). -export NIX_CFLAGS_COMPILE="-B$param4/lib -isystem $param4/include $NIX_CFLAGS_COMPILE" -export NIX_CFLAGS_LINK="-L$param4/lib -L$param2/lib $NIX_CFLAGS_LINK" -export NIX_LDFLAGS="-dynamic-linker $param4/lib/ld-linux.so.2 -rpath $param4/lib -rpath $param2/lib $NIX_LDFLAGS" - -export NIX_LIBC_INCLUDES="$param4/include" -export NIX_LIBC_LIBS="$param4/lib" +export NIX_ENFORCE_PURITY=1 diff --git a/pkgs/stdenv/nix/posthook.sh b/pkgs/stdenv/nix/posthook.sh deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/pkgs/system/all-packages-generic.nix b/pkgs/system/all-packages-generic.nix index 4de6e4ca502..d656845994e 100644 --- a/pkgs/system/all-packages-generic.nix +++ b/pkgs/system/all-packages-generic.nix @@ -198,12 +198,12 @@ }; gcc = (import ../development/compilers/gcc) { - inherit fetchurl stdenv binutils; + inherit fetchurl stdenv; }; g77 = (import ../build-support/gcc-wrapper) { inherit stdenv; - gcc = (import ../development/compilers/gcc-new) { + gcc = (import ../development/compilers/gcc) { inherit fetchurl stdenv; langF77 = true; langCC = false; diff --git a/pkgs/system/stdenvs.nix b/pkgs/system/stdenvs.nix index 06a9fc50fed..d770d687499 100644 --- a/pkgs/system/stdenvs.nix +++ b/pkgs/system/stdenvs.nix @@ -44,7 +44,7 @@ # 2) Construct a stdenv consisting of the native build environment, # plus the pure glibc. stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) { - system = system; + stdenv = stdenvInitial; glibc = stdenvLinuxGlibc; }; @@ -56,7 +56,7 @@ # might end up linking against /lib/libncurses). So repeat, but # now use the Nix-built tools from step 2/3. stdenvLinuxBoot2 = (import ../stdenv/nix-linux) { - bootStdenv = stdenvLinuxBoot1; + stdenv = stdenvLinuxBoot1; pkgs = stdenvLinuxBoot1Pkgs; glibc = stdenvLinuxGlibc; }; diff --git a/pkgs/test/simple/builder.sh b/pkgs/test/simple/builder.sh index 282fc520bd1..58bf16c43b3 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_ENFORCE_PURITY=1 mkdir $out mkdir $out/bin @@ -24,6 +24,8 @@ gcc -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello $out/bin/hello +exit 0 + cat > hello2.cc < diff --git a/pkgs/test/simple/default.nix b/pkgs/test/simple/default.nix index 2d582f03a51..9374a6ede28 100644 --- a/pkgs/test/simple/default.nix +++ b/pkgs/test/simple/default.nix @@ -1,12 +1,12 @@ let { system = "i686-linux"; - stdenvInitial = (import ../../stdenv/initial) { - name = "stdenv-initial"; - inherit system; + stdenvs = (import ../../system/stdenvs.nix) { + system = "i686-linux"; + allPackages = import ../../system/all-packages-generic.nix; }; - stdenv = (import ../../stdenv/native) {stdenv = stdenvInitial;}; + stdenv = stdenvs.stdenvLinuxBoot1; test = derivation { name = "simple-test"; -- cgit 1.4.1