* 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:
parent
de13527000
commit
0fd59fd7a4
@ -56,6 +56,7 @@ ln -s g77 $out/bin/f77
|
|||||||
|
|
||||||
|
|
||||||
sed \
|
sed \
|
||||||
|
-e "s^@out@^$out^g" \
|
||||||
-e "s^@ldflags@^$ldflags^g" \
|
-e "s^@ldflags@^$ldflags^g" \
|
||||||
-e "s^@ld@^$ldPath/ld^g" \
|
-e "s^@ld@^$ldPath/ld^g" \
|
||||||
< $ldWrapper > $out/bin/ld
|
< $ldWrapper > $out/bin/ld
|
||||||
@ -63,7 +64,7 @@ chmod +x $out/bin/ld
|
|||||||
|
|
||||||
|
|
||||||
mkdir $out/nix-support
|
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
|
test -n "$glibc" && echo $glibc > $out/nix-support/orig-glibc
|
||||||
|
|
||||||
cat > $out/nix-support/add-flags <<EOF
|
cat > $out/nix-support/add-flags <<EOF
|
||||||
@ -77,3 +78,5 @@ sed \
|
|||||||
-e "s^@binutils@^$binutils^g" \
|
-e "s^@binutils@^$binutils^g" \
|
||||||
-e "s^@glibc@^$glibc^g" \
|
-e "s^@glibc@^$glibc^g" \
|
||||||
< $setupHook > $out/nix-support/setup-hook
|
< $setupHook > $out/nix-support/setup-hook
|
||||||
|
|
||||||
|
cp -p $utils $out/nix-support/utils
|
@ -19,6 +19,7 @@ derivation {
|
|||||||
setupHook = ./setup-hook.sh;
|
setupHook = ./setup-hook.sh;
|
||||||
gccWrapper = ./gcc-wrapper.sh;
|
gccWrapper = ./gcc-wrapper.sh;
|
||||||
ldWrapper = ./ld-wrapper.sh;
|
ldWrapper = ./ld-wrapper.sh;
|
||||||
|
utils = ./utils.sh;
|
||||||
inherit name stdenv nativeTools nativeGlibc nativePrefix gcc glibc binutils;
|
inherit name stdenv nativeTools nativeGlibc nativePrefix gcc glibc binutils;
|
||||||
langC = if nativeTools then true else gcc.langC;
|
langC = if nativeTools then true else gcc.langC;
|
||||||
langCC = if nativeTools then true else gcc.langCC;
|
langCC = if nativeTools then true else gcc.langCC;
|
||||||
|
@ -8,6 +8,8 @@ if test -z "$NIX_GLIBC_FLAGS_SET"; then
|
|||||||
. @out@/nix-support/add-flags
|
. @out@/nix-support/add-flags
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
. @out@/nix-support/utils
|
||||||
|
|
||||||
|
|
||||||
# Figure out if linker flags should be passed. GCC prints annoying
|
# Figure out if linker flags should be passed. GCC prints annoying
|
||||||
# warnings when they are not needed.
|
# warnings when they are not needed.
|
||||||
@ -34,19 +36,8 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
# Optionally filter out paths not refering to the store.
|
# 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=("$@")
|
params=("$@")
|
||||||
if test "$NIX_ENFORCE_PURITY" = "1x" -a -n "$NIX_STORE"; then
|
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
||||||
rest=()
|
rest=()
|
||||||
n=0
|
n=0
|
||||||
while test $n -lt ${#params[*]}; do
|
while test $n -lt ${#params[*]}; do
|
||||||
|
@ -4,30 +4,29 @@ if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
|
|||||||
. "$NIX_LD_WRAPPER_START_HOOK"
|
. "$NIX_LD_WRAPPER_START_HOOK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Optionally filter out paths not refering to the store.
|
. @out@/nix-support/utils
|
||||||
skip () {
|
|
||||||
if test "$NIX_DEBUG" = "1"; then
|
|
||||||
echo "skipping impure path $1" >&2
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
# Optionally filter out paths not refering to the store.
|
||||||
params=("$@")
|
params=("$@")
|
||||||
if test "$NIX_ENFORCE_PURITY" = "1x" -a -n "$NIX_STORE"; then
|
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
||||||
rest=()
|
rest=()
|
||||||
n=0
|
n=0
|
||||||
while test $n -lt ${#params[*]}; do
|
while test $n -lt ${#params[*]}; do
|
||||||
p=${params[n]}
|
p=${params[n]}
|
||||||
p2=${params[$((n+1))]}
|
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
|
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
|
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
|
n=$((n + 1)); skip $p2
|
||||||
# elif test "${p:0:1}" = "/" -a "${p:0:${#NIX_STORE}}" != "$NIX_STORE"; then
|
elif test "$p" = "-dynamic-linker" && badPath "$p2"; then
|
||||||
# # We cannot skip this; barf.
|
n=$((n + 1)); skip $p2
|
||||||
# echo "impure path \`$p' used in link"
|
elif test "${p:0:1}" = "/" && badPath "$p"; then
|
||||||
# exit 1
|
# We cannot skip this; barf.
|
||||||
|
echo "impure path \`$p' used in link" >&2
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
rest=("${rest[@]}" "$p")
|
rest=("${rest[@]}" "$p")
|
||||||
fi
|
fi
|
||||||
@ -43,6 +42,7 @@ if test -z "$NIX_LDFLAGS_SET"; then
|
|||||||
extra=(${extra[@]} $NIX_LDFLAGS)
|
extra=(${extra[@]} $NIX_LDFLAGS)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Optionally print debug info.
|
||||||
if test "$NIX_DEBUG" = "1"; then
|
if test "$NIX_DEBUG" = "1"; then
|
||||||
echo "original flags to @ld@:" >&2
|
echo "original flags to @ld@:" >&2
|
||||||
for i in "${params[@]}"; do
|
for i in "${params[@]}"; do
|
||||||
|
13
pkgs/build-support/gcc-wrapper/utils.sh
Normal file
13
pkgs/build-support/gcc-wrapper/utils.sh
Normal 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"
|
||||||
|
}
|
@ -69,8 +69,6 @@ addToEnv()
|
|||||||
export _PATH=$_PATH:$1/bin
|
export _PATH=$_PATH:$1/bin
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "${envHooks[@]}"
|
|
||||||
|
|
||||||
for i in "${envHooks[@]}"; do
|
for i in "${envHooks[@]}"; do
|
||||||
$i $pkg
|
$i $pkg
|
||||||
done
|
done
|
||||||
@ -92,8 +90,20 @@ export NIX_STRIP_DEBUG=1
|
|||||||
export NIX_CFLAGS_STRIP="-g0 -Wl,-s"
|
export NIX_CFLAGS_STRIP="-g0 -Wl,-s"
|
||||||
|
|
||||||
|
|
||||||
# Where is the store? This is required for purity checking.
|
# Do we know where the store is? This is required for purity checking.
|
||||||
export NIX_STORE=$(dirname $out)/ # !!! hack
|
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
|
# Set the TZ (timezone) environment variable, otherwise commands like
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
{stdenv, pkgs, glibc}:
|
{stdenv, glibc}:
|
||||||
|
|
||||||
(import ../generic) {
|
(import ../generic) {
|
||||||
name = "stdenv-nix-linux-boot";
|
name = "stdenv-nix-linux-boot";
|
||||||
preHook = ./prehook-boot.sh;
|
preHook = ./prehook-boot.sh;
|
||||||
initialPath = (import ../nix/path.nix) {pkgs = pkgs;};
|
initialPath = "/usr/local /usr /";
|
||||||
|
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
|
|
||||||
gcc = (import ../../build-support/gcc-wrapper) {
|
gcc = (import ../../build-support/gcc-wrapper) {
|
||||||
name = pkgs.gcc.name;
|
name = "gcc-native";
|
||||||
nativeTools = false;
|
nativeTools = true;
|
||||||
nativeGlibc = false;
|
nativeGlibc = false;
|
||||||
inherit (pkgs) gcc binutils;
|
nativePrefix = "/usr";
|
||||||
inherit stdenv glibc;
|
inherit stdenv glibc;
|
||||||
};
|
};
|
||||||
|
|
||||||
param1 = pkgs.bash;
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
{stdenv, glibc, pkgs}:
|
{stdenv, glibc, pkgs, genericStdenv, gccWrapper}:
|
||||||
|
|
||||||
(import ../generic) {
|
genericStdenv {
|
||||||
name = "stdenv-nix-linux";
|
name = "stdenv-nix-linux";
|
||||||
preHook = ./prehook.sh;
|
preHook = ./prehook.sh;
|
||||||
initialPath = (import ../nix/path.nix) {pkgs = pkgs;};
|
initialPath = (import ../nix/path.nix) {pkgs = pkgs;};
|
||||||
|
|
||||||
inherit stdenv;
|
inherit stdenv;
|
||||||
|
|
||||||
gcc = (import ../../build-support/gcc-wrapper) {
|
gcc = gccWrapper {
|
||||||
name = pkgs.gcc.name;
|
name = pkgs.gcc.name;
|
||||||
nativeTools = false;
|
nativeTools = false;
|
||||||
nativeGlibc = false;
|
nativeGlibc = false;
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export SHELL=$param1
|
export SHELL=/bin/sh
|
||||||
|
|
||||||
export NIX_ENFORCE_PURITY=
|
export NIX_ENFORCE_PURITY=
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
{system, allPackages}: rec {
|
{system, allPackages}: rec {
|
||||||
|
|
||||||
|
gccWrapper = import ../build-support/gcc-wrapper;
|
||||||
|
genericStdenv = import ../stdenv/generic;
|
||||||
|
|
||||||
|
|
||||||
# Trivial environment used for building other environments.
|
# Trivial environment used for building other environments.
|
||||||
stdenvInitial = (import ../stdenv/initial) {
|
stdenvInitial = (import ../stdenv/initial) {
|
||||||
@ -45,7 +48,6 @@
|
|||||||
# plus the pure glibc.
|
# plus the pure glibc.
|
||||||
stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) {
|
stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) {
|
||||||
stdenv = stdenvNative;
|
stdenv = stdenvNative;
|
||||||
pkgs = allPackages {stdenv = stdenvNative; noSysDirs = false;};
|
|
||||||
glibc = stdenvLinuxGlibc;
|
glibc = stdenvLinuxGlibc;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,6 +62,7 @@
|
|||||||
stdenv = stdenvLinuxBoot1;
|
stdenv = stdenvLinuxBoot1;
|
||||||
pkgs = stdenvLinuxBoot1Pkgs;
|
pkgs = stdenvLinuxBoot1Pkgs;
|
||||||
glibc = stdenvLinuxGlibc;
|
glibc = stdenvLinuxGlibc;
|
||||||
|
inherit genericStdenv gccWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
# 5) These packages should be pure.
|
# 5) These packages should be pure.
|
||||||
@ -70,6 +73,7 @@
|
|||||||
stdenv = stdenvLinuxBoot2;
|
stdenv = stdenvLinuxBoot2;
|
||||||
pkgs = stdenvLinuxBoot2Pkgs;
|
pkgs = stdenvLinuxBoot2Pkgs;
|
||||||
glibc = stdenvLinuxGlibc;
|
glibc = stdenvLinuxGlibc;
|
||||||
|
inherit genericStdenv gccWrapper;
|
||||||
};
|
};
|
||||||
|
|
||||||
# 7) And we can build all packages against that, but we don't
|
# 7) And we can build all packages against that, but we don't
|
||||||
|
@ -6,10 +6,7 @@ export NIX_DEBUG=1
|
|||||||
|
|
||||||
. $stdenv/setup
|
. $stdenv/setup
|
||||||
|
|
||||||
#echo starting shell
|
export NIX_ENFORCE_PURITY=1
|
||||||
#/bin/sh < /dev/tty > /dev/tty 2>&1
|
|
||||||
|
|
||||||
#exit 1
|
|
||||||
|
|
||||||
mkdir $out
|
mkdir $out
|
||||||
mkdir $out/bin
|
mkdir $out/bin
|
||||||
@ -25,7 +22,7 @@ int main(int argc, char * * argv)
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
#gcc -I/nix/store/foo -I /nix/store/foo -I/usr/lib -I /usr/lib 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
|
gcc -I`pwd` -L /nix/store/abcd/lib -isystem /usr/lib hello.c -o $out/bin/hello
|
||||||
|
|
||||||
$out/bin/hello
|
$out/bin/hello
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ let {
|
|||||||
allPackages = import ../../system/all-packages-generic.nix;
|
allPackages = import ../../system/all-packages-generic.nix;
|
||||||
};
|
};
|
||||||
|
|
||||||
stdenv = stdenvs.stdenvLinuxBoot2;
|
stdenv = stdenvs.stdenvLinux;
|
||||||
|
|
||||||
test = derivation {
|
test = derivation {
|
||||||
name = "simple-test";
|
name = "simple-test";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user