1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-19 04:02:10 +00:00

* Re-enabled purity checking: it should work now. First we only

checked whether absolute paths passed to gcc/ld refer to the store,
  which is wrong: they can also refer to the build tree
  (/tmp/nix-...).

* Less static composition in the construction of stdenv-nix-linux:
  gcc-wrapper and generic are now passed in as arguments, rather then
  referenced by relative path.  This makes it easier to hack on a
  specific stage of the bootstrap process (before, a change to, e.g.,
  generic/setup.sh would cause all bootstrap stages to be redone).

svn path=/nixpkgs/trunk/; revision=833
This commit is contained in:
Eelco Dolstra 2004-03-12 11:12:18 +00:00
parent de13527000
commit 0fd59fd7a4
12 changed files with 67 additions and 50 deletions

View file

@ -56,6 +56,7 @@ ln -s g77 $out/bin/f77
sed \
-e "s^@out@^$out^g" \
-e "s^@ldflags@^$ldflags^g" \
-e "s^@ld@^$ldPath/ld^g" \
< $ldWrapper > $out/bin/ld
@ -63,7 +64,7 @@ chmod +x $out/bin/ld
mkdir $out/nix-support
test -z "$gcc" && echo $gcc > $out/nix-support/orig-gcc
test -n "$gcc" && echo $gcc > $out/nix-support/orig-gcc
test -n "$glibc" && echo $glibc > $out/nix-support/orig-glibc
cat > $out/nix-support/add-flags <<EOF
@ -77,3 +78,5 @@ sed \
-e "s^@binutils@^$binutils^g" \
-e "s^@glibc@^$glibc^g" \
< $setupHook > $out/nix-support/setup-hook
cp -p $utils $out/nix-support/utils

View file

@ -19,6 +19,7 @@ derivation {
setupHook = ./setup-hook.sh;
gccWrapper = ./gcc-wrapper.sh;
ldWrapper = ./ld-wrapper.sh;
utils = ./utils.sh;
inherit name stdenv nativeTools nativeGlibc nativePrefix gcc glibc binutils;
langC = if nativeTools then true else gcc.langC;
langCC = if nativeTools then true else gcc.langCC;

View file

@ -8,13 +8,15 @@ if test -z "$NIX_GLIBC_FLAGS_SET"; then
. @out@/nix-support/add-flags
fi
. @out@/nix-support/utils
# Figure out if linker flags should be passed. GCC prints annoying
# warnings when they are not needed.
dontLink=0
if test "$*" = "-v" -o -z "$*"; then
dontLink=1
else
else
for i in "$@"; do
if test "$i" = "-c"; then
dontLink=1
@ -34,19 +36,8 @@ fi
# Optionally filter out paths not refering to the store.
skip () {
if test "$NIX_DEBUG" = "1"; then
echo "skipping impure path $1" >&2
fi
}
badPath() {
p=$1
test "${p:0:${#NIX_STORE}}" = "$NIX_STORE" -o "${p:0:4}" = "/tmp"
}
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1x" -a -n "$NIX_STORE"; then
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
rest=()
n=0
while test $n -lt ${#params[*]}; do

View file

@ -4,30 +4,29 @@ if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
. "$NIX_LD_WRAPPER_START_HOOK"
fi
# Optionally filter out paths not refering to the store.
skip () {
if test "$NIX_DEBUG" = "1"; then
echo "skipping impure path $1" >&2
fi
}
. @out@/nix-support/utils
# Optionally filter out paths not refering to the store.
params=("$@")
if test "$NIX_ENFORCE_PURITY" = "1x" -a -n "$NIX_STORE"; then
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
if test "${p:0:3}" = "-L/" && badPath "${p:2}"; then
skip $p
elif test "$p" = "-L" -a "${p2:0:${#NIX_STORE}}" != "$NIX_STORE"; then
elif test "$p" = "-L" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "$p" = "-dynamic-linker" -a "${p2:0:${#NIX_STORE}}" != "$NIX_STORE"; then
elif test "$p" = "-rpath" && badPath "$p2"; then
n=$((n + 1)); skip $p2
# elif test "${p:0:1}" = "/" -a "${p:0:${#NIX_STORE}}" != "$NIX_STORE"; then
# # We cannot skip this; barf.
# echo "impure path \`$p' used in link"
# exit 1
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
n=$((n + 1)); skip $p2
elif test "${p:0:1}" = "/" && badPath "$p"; then
# We cannot skip this; barf.
echo "impure path \`$p' used in link" >&2
exit 1
else
rest=("${rest[@]}" "$p")
fi
@ -43,6 +42,7 @@ if test -z "$NIX_LDFLAGS_SET"; then
extra=(${extra[@]} $NIX_LDFLAGS)
fi
# Optionally print debug info.
if test "$NIX_DEBUG" = "1"; then
echo "original flags to @ld@:" >&2
for i in "${params[@]}"; do

View file

@ -0,0 +1,13 @@
skip () {
if test "$NIX_DEBUG" = "1"; then
echo "skipping impure path $1" >&2
fi
}
badPath() {
local p=$1
test \
"${p:0:${#NIX_STORE}}" != "$NIX_STORE" -a \
"${p:0:4}" != "/tmp" -a \
"${p:0:${#NIX_BUILD_TOP}}" != "$NIX_BUILD_TOP"
}

View file

@ -69,8 +69,6 @@ addToEnv()
export _PATH=$_PATH:$1/bin
fi
echo "${envHooks[@]}"
for i in "${envHooks[@]}"; do
$i $pkg
done
@ -92,8 +90,20 @@ 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
# Do we know where the store is? This is required for purity checking.
if test -z "$NIX_STORE"; then
echo "Error: you have an old version of Nix that does not set the" \
"NIX_STORE variable. Please upgrade." >&2
exit 1
fi
# We also need to know the root of the build directory for purity checking.
if test -z "$NIX_BUILD_TOP"; then
echo "Error: you have an old version of Nix that does not set the" \
"NIX_BUILD_TOP variable. Please upgrade." >&2
exit 1
fi
# Set the TZ (timezone) environment variable, otherwise commands like

View file

@ -1,19 +1,17 @@
{stdenv, pkgs, glibc}:
{stdenv, glibc}:
(import ../generic) {
name = "stdenv-nix-linux-boot";
preHook = ./prehook-boot.sh;
initialPath = (import ../nix/path.nix) {pkgs = pkgs;};
initialPath = "/usr/local /usr /";
inherit stdenv;
gcc = (import ../../build-support/gcc-wrapper) {
name = pkgs.gcc.name;
nativeTools = false;
name = "gcc-native";
nativeTools = true;
nativeGlibc = false;
inherit (pkgs) gcc binutils;
nativePrefix = "/usr";
inherit stdenv glibc;
};
param1 = pkgs.bash;
}

View file

@ -1,13 +1,13 @@
{stdenv, glibc, pkgs}:
{stdenv, glibc, pkgs, genericStdenv, gccWrapper}:
(import ../generic) {
genericStdenv {
name = "stdenv-nix-linux";
preHook = ./prehook.sh;
initialPath = (import ../nix/path.nix) {pkgs = pkgs;};
inherit stdenv;
gcc = (import ../../build-support/gcc-wrapper) {
gcc = gccWrapper {
name = pkgs.gcc.name;
nativeTools = false;
nativeGlibc = false;

View file

@ -1,3 +1,3 @@
export SHELL=$param1
export SHELL=/bin/sh
export NIX_ENFORCE_PURITY=

View file

@ -7,6 +7,9 @@
{system, allPackages}: rec {
gccWrapper = import ../build-support/gcc-wrapper;
genericStdenv = import ../stdenv/generic;
# Trivial environment used for building other environments.
stdenvInitial = (import ../stdenv/initial) {
@ -45,7 +48,6 @@
# plus the pure glibc.
stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) {
stdenv = stdenvNative;
pkgs = allPackages {stdenv = stdenvNative; noSysDirs = false;};
glibc = stdenvLinuxGlibc;
};
@ -60,6 +62,7 @@
stdenv = stdenvLinuxBoot1;
pkgs = stdenvLinuxBoot1Pkgs;
glibc = stdenvLinuxGlibc;
inherit genericStdenv gccWrapper;
};
# 5) These packages should be pure.
@ -70,6 +73,7 @@
stdenv = stdenvLinuxBoot2;
pkgs = stdenvLinuxBoot2Pkgs;
glibc = stdenvLinuxGlibc;
inherit genericStdenv gccWrapper;
};
# 7) And we can build all packages against that, but we don't

View file

@ -6,10 +6,7 @@ export NIX_DEBUG=1
. $stdenv/setup
#echo starting shell
#/bin/sh < /dev/tty > /dev/tty 2>&1
#exit 1
export NIX_ENFORCE_PURITY=1
mkdir $out
mkdir $out/bin
@ -25,7 +22,7 @@ int main(int argc, char * * argv)
EOF
#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
gcc -I`pwd` -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello
$out/bin/hello

View file

@ -6,7 +6,7 @@ let {
allPackages = import ../../system/all-packages-generic.nix;
};
stdenv = stdenvs.stdenvLinuxBoot2;
stdenv = stdenvs.stdenvLinux;
test = derivation {
name = "simple-test";