From 15103e5e5fb01556e9c5758ef99d7e7f5d0f7699 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 1 Jul 2014 16:17:23 +0200 Subject: stdenv: Remove the special handling of gcc Now gcc is just another build input, making it possible in the future to have a stdenv that doesn't depend on a C compiler. This is very useful on NixOS, since it would allow trivial builders like writeTextFile to work without pulling in the C compiler. --- pkgs/build-support/clang-wrapper/setup-hook.sh | 2 + pkgs/build-support/gcc-wrapper/setup-hook.sh | 2 + pkgs/stdenv/generic/builder.sh | 1 - pkgs/stdenv/generic/default.nix | 5 ++- pkgs/stdenv/generic/setup.sh | 53 ++++++++++++-------------- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/pkgs/build-support/clang-wrapper/setup-hook.sh b/pkgs/build-support/clang-wrapper/setup-hook.sh index f7687651eaf..538e6263e72 100644 --- a/pkgs/build-support/clang-wrapper/setup-hook.sh +++ b/pkgs/build-support/clang-wrapper/setup-hook.sh @@ -1,3 +1,5 @@ +export NIX_GCC=@out@ + addCVars () { if test -d $1/include; then export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" diff --git a/pkgs/build-support/gcc-wrapper/setup-hook.sh b/pkgs/build-support/gcc-wrapper/setup-hook.sh index 298ade21d1f..ea762e9b405 100644 --- a/pkgs/build-support/gcc-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-wrapper/setup-hook.sh @@ -1,3 +1,5 @@ +export NIX_GCC=@out@ + addCVars () { if test -d $1/include; then export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -isystem $1/include" diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh index fd4c17ca251..fc41976b7d1 100644 --- a/pkgs/stdenv/generic/builder.sh +++ b/pkgs/stdenv/generic/builder.sh @@ -10,7 +10,6 @@ echo "$preHook" > $out/setup cat "$setup" >> $out/setup sed -e "s^@initialPath@^$initialPath^g" \ - -e "s^@gcc@^$gcc^g" \ -e "s^@shell@^$shell^g" \ < $out/setup > $out/setup.tmp mv $out/setup.tmp $out/setup diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 28a3c1e9f3b..3d9cec05a35 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -33,6 +33,7 @@ let [ ../../build-support/setup-hooks/compress-man-pages.sh ../../build-support/setup-hooks/strip.sh ../../build-support/setup-hooks/patch-shebangs.sh + gcc ]; # The stdenv that we are producing. @@ -52,7 +53,7 @@ let setup = setupScript; - inherit preHook initialPath gcc shell; + inherit preHook initialPath shell; propagatedUserEnvPkgs = [gcc] ++ lib.filter lib.isDerivation initialPath; @@ -186,6 +187,8 @@ let inherit fetchurlBoot; inherit overrides; + + inherit gcc; } # Propagate any extra attributes. For instance, we use this to diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 72db7dc6004..675d8ce797d 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -1,3 +1,5 @@ +set -e + : ${outputs:=out} @@ -115,7 +117,7 @@ trap "exitHandler" EXIT ###################################################################### -# Helper functions that might be useful in setup hooks. +# Helper functions. addToSearchPathWithCustomDelimiter() { @@ -134,12 +136,23 @@ addToSearchPath() { } -###################################################################### -# Initialisation. +ensureDir() { + echo "warning: ‘ensureDir’ is deprecated; use ‘mkdir’ instead" >&2 + local dir + for dir in "$@"; do + if ! [ -x "$dir" ]; then mkdir -p "$dir"; fi + done +} + + +installBin() { + mkdir -p $out/bin + cp "$@" $out/bin +} -set -e -[ -z $NIX_GCC ] && NIX_GCC=@gcc@ +###################################################################### +# Initialisation. # Wildcard expansions that don't match should expand to an empty list. @@ -150,7 +163,7 @@ shopt -s nullglob # Set up the initial path. PATH= -for i in $NIX_GCC @initialPath@; do +for i in @initialPath@; do if [ "$i" = / ]; then i=; fi addToSearchPath PATH $i/bin addToSearchPath PATH $i/sbin @@ -171,27 +184,9 @@ runHook preHook # Check that the pre-hook initialised SHELL. if [ -z "$SHELL" ]; then echo "SHELL not set"; exit 1; fi -# Hack: run gcc's setup hook. + envHooks=() crossEnvHooks=() -if [ -f $NIX_GCC/nix-support/setup-hook ]; then - source $NIX_GCC/nix-support/setup-hook -fi - - -# Ensure that the given directories exists. -ensureDir() { - echo "warning: ‘ensureDir’ is deprecated; use ‘mkdir’ instead" >&2 - local dir - for dir in "$@"; do - if ! [ -x "$dir" ]; then mkdir -p "$dir"; fi - done -} - -installBin() { - mkdir -p $out/bin - cp "$@" $out/bin -} # Allow the caller to augment buildInputs (it's not always possible to @@ -242,7 +237,7 @@ done # Set the relevant environment variables to point to the build inputs # found above. -addToNativeEnv() { +_addToNativeEnv() { local pkg=$1 if [ -d $1/bin ]; then @@ -256,10 +251,10 @@ addToNativeEnv() { } for i in $nativePkgs; do - addToNativeEnv $i + _addToNativeEnv $i done -addToCrossEnv() { +_addToCrossEnv() { local pkg=$1 # Some programs put important build scripts (freetype-config and similar) @@ -276,7 +271,7 @@ addToCrossEnv() { } for i in $crossPkgs; do - addToCrossEnv $i + _addToCrossEnv $i done -- cgit 1.4.1