mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
* Finally we have a working stdenvLinux again.
On the downside, the build process of stdenvLinux builds gcc 9 times (3 x 3 bootstrap stages). That's a bit excessive. svn path=/nixpkgs/trunk/; revision=880
This commit is contained in:
parent
68327c3a9d
commit
01a1658c6b
@ -39,7 +39,7 @@ mkGccWrapper () {
|
||||
sed \
|
||||
-e "s^@gcc@^$src^g" \
|
||||
-e "s^@out@^$out^g" \
|
||||
-e "s^@bash@^$SHELL^g" \
|
||||
-e "s^@shell@^$shell^g" \
|
||||
< $gccWrapper > $dst
|
||||
chmod +x $dst
|
||||
}
|
||||
@ -58,7 +58,7 @@ sed \
|
||||
-e "s^@out@^$out^g" \
|
||||
-e "s^@ldflags@^$ldflags^g" \
|
||||
-e "s^@ld@^$ldPath/ld^g" \
|
||||
-e "s^@bash@^$SHELL^g" \
|
||||
-e "s^@shell@^$shell^g" \
|
||||
< $ldWrapper > $out/bin/ld
|
||||
chmod +x $out/bin/ld
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
# variables so that the compiler and the linker just "work".
|
||||
|
||||
{ name, stdenv, nativeTools, nativeGlibc, nativePrefix ? ""
|
||||
, gcc ? null, glibc ? null, binutils ? null
|
||||
, gcc ? null, glibc ? null, binutils ? null, shell ? ""
|
||||
}:
|
||||
|
||||
assert nativeTools -> nativePrefix != "";
|
||||
@ -23,4 +23,5 @@ stdenv.mkDerivation {
|
||||
langC = if nativeTools then true else gcc.langC;
|
||||
langCC = if nativeTools then true else gcc.langCC;
|
||||
langF77 = if nativeTools then false else gcc.langF77;
|
||||
shell = if shell == "" then stdenv.shell else shell;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#! @bash@ -e
|
||||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_GCC_WRAPPER_START_HOOK"; then
|
||||
. "$NIX_GCC_WRAPPER_START_HOOK"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#! @bash@ -e
|
||||
#! @shell@ -e
|
||||
|
||||
if test -n "$NIX_LD_WRAPPER_START_HOOK"; then
|
||||
. "$NIX_LD_WRAPPER_START_HOOK"
|
||||
@ -9,7 +9,8 @@ fi
|
||||
|
||||
# Optionally filter out paths not refering to the store.
|
||||
params=("$@")
|
||||
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE"; then
|
||||
if test "$NIX_ENFORCE_PURITY" = "1" -a -n "$NIX_STORE" \
|
||||
-a \( -z "$NIX_IGNORE_LD_THROUGH_GCC" -o -z "$NIX_LDFLAGS_SET" \); then
|
||||
rest=()
|
||||
n=0
|
||||
while test $n -lt ${#params[*]}; do
|
||||
|
@ -13,6 +13,7 @@ sed \
|
||||
-e "s^@postHook@^$postHook^g" \
|
||||
-e "s^@initialPath@^$initialPath^g" \
|
||||
-e "s^@gcc@^$gcc^g" \
|
||||
-e "s^@shell@^$shell^g" \
|
||||
-e "s^@param1@^$p1^g" \
|
||||
-e "s^@param2@^$p2^g" \
|
||||
-e "s^@param3@^$p3^g" \
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, bash
|
||||
{ stdenv, name, preHook ? null, postHook ? null, initialPath, gcc, shell
|
||||
, param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? ""
|
||||
}:
|
||||
|
||||
@ -13,17 +13,17 @@ let {
|
||||
|
||||
setup = ./setup.sh;
|
||||
|
||||
inherit preHook postHook initialPath gcc;
|
||||
inherit preHook postHook initialPath gcc shell;
|
||||
|
||||
# TODO: make this more elegant.
|
||||
inherit param1 param2 param3 param4 param5;
|
||||
}
|
||||
|
||||
# Add a utility function to produce derivations that use this
|
||||
# stdenv and its the bash shell.
|
||||
# stdenv and its shell.
|
||||
// {
|
||||
mkDerivation = attrs: derivation (attrs // {
|
||||
builder = bash;
|
||||
builder = shell;
|
||||
args = ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
|
||||
stdenv = body;
|
||||
system = body.system;
|
||||
|
@ -15,6 +15,7 @@ fi
|
||||
|
||||
|
||||
# Execute the pre-hook.
|
||||
export SHELL=@shell@
|
||||
param1=@param1@
|
||||
param2=@param2@
|
||||
param3=@param3@
|
||||
|
@ -7,21 +7,25 @@
|
||||
|
||||
let {
|
||||
|
||||
shell = "/bin/sh";
|
||||
|
||||
body =
|
||||
|
||||
derivation {
|
||||
inherit system name;
|
||||
builder = "/bin/sh";
|
||||
builder = shell;
|
||||
args = ["-e" ./builder.sh];
|
||||
}
|
||||
|
||||
// {
|
||||
mkDerivation = attrs: derivation (attrs // {
|
||||
builder = "/bin/sh";
|
||||
builder = shell;
|
||||
args = ["-e" attrs.builder];
|
||||
stdenv = body;
|
||||
system = body.system;
|
||||
});
|
||||
|
||||
inherit shell;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ genericStdenv {
|
||||
inherit stdenv;
|
||||
};
|
||||
|
||||
bash = "/bin/sh";
|
||||
shell = "/bin/sh";
|
||||
}
|
||||
|
@ -1,3 +1 @@
|
||||
export SHELL=/bin/sh
|
||||
|
||||
export NIX_ENFORCE_PURITY=
|
||||
|
@ -1,19 +0,0 @@
|
||||
{stdenv, glibc, genericStdenv, gccWrapper}:
|
||||
|
||||
genericStdenv {
|
||||
name = "stdenv-nix-linux-boot";
|
||||
preHook = ./prehook-boot.sh;
|
||||
initialPath = "/usr/local /usr /";
|
||||
|
||||
inherit stdenv;
|
||||
|
||||
gcc = gccWrapper {
|
||||
name = "gcc-native";
|
||||
nativeTools = true;
|
||||
nativeGlibc = false;
|
||||
nativePrefix = "/usr";
|
||||
inherit stdenv glibc;
|
||||
};
|
||||
|
||||
bash = "/bin/sh";
|
||||
}
|
@ -12,10 +12,9 @@ genericStdenv {
|
||||
nativeTools = false;
|
||||
nativeGlibc = false;
|
||||
inherit (pkgs) gcc binutils;
|
||||
inherit glibc;
|
||||
inherit stdenv glibc;
|
||||
shell = pkgs.bash ~ /bin/sh;
|
||||
};
|
||||
|
||||
bash = pkgs.bash ~ /bin/sh;
|
||||
|
||||
param1 = pkgs.bash;
|
||||
shell = pkgs.bash ~ /bin/sh;
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
export SHELL=/bin/sh
|
||||
|
||||
export NIX_ENFORCE_PURITY=
|
@ -1,3 +1 @@
|
||||
export SHELL=$param1
|
||||
|
||||
export NIX_ENFORCE_PURITY=1
|
||||
|
@ -13,9 +13,8 @@ genericStdenv {
|
||||
nativeGlibc = true;
|
||||
inherit (pkgs) gcc binutils;
|
||||
inherit stdenv;
|
||||
shell = pkgs.bash ~ /bin/sh;
|
||||
};
|
||||
|
||||
bash = pkgs.bash ~ /bin/sh;
|
||||
|
||||
param1 = pkgs.bash;
|
||||
shell = pkgs.bash ~ /bin/sh;
|
||||
}
|
||||
|
@ -1 +1,2 @@
|
||||
export SHELL=$param1
|
||||
export NIX_ENFORCE_PURITY=1
|
||||
export NIX_IGNORE_LD_THROUGH_GCC=1
|
||||
|
@ -38,19 +38,14 @@
|
||||
# The Nix build environment.
|
||||
stdenvNix = (import ../stdenv/nix) {
|
||||
stdenv = stdenvNative;
|
||||
pkgs = stdenvNixBootPkgs;
|
||||
pkgs = stdenvNativePkgs;
|
||||
inherit genericStdenv gccWrapper;
|
||||
};
|
||||
|
||||
stdenvNixBootPkgs = allPackages {
|
||||
stdenv = stdenvNative;
|
||||
bootCurl = null;
|
||||
noSysDirs = true;
|
||||
};
|
||||
|
||||
stdenvNixPkgs = allPackages {
|
||||
stdenv = stdenvNix;
|
||||
bootCurl = stdenvNixBootPkgs.curl;
|
||||
bootCurl = stdenvNativePkgs.curl;
|
||||
noSysDirs = false;
|
||||
};
|
||||
|
||||
|
||||
@ -59,40 +54,53 @@
|
||||
|
||||
# 1) Build glibc in the Nix build environment. The result is
|
||||
# pure.
|
||||
stdenvLinuxGlibc = stdenvNativePkgs.glibc; # !!! should be NixPkgs, but doesn't work
|
||||
stdenvLinuxGlibc = stdenvNixPkgs.glibc;
|
||||
|
||||
# 2) Construct a stdenv consisting of the native build environment,
|
||||
# plus the pure glibc.
|
||||
stdenvLinuxBoot1 = (import ../stdenv/nix-linux/boot.nix) {
|
||||
# 2) Construct a stdenv consisting of the Nix build environment, but
|
||||
# with a gcc-wrapper that causes linking against the glibc from
|
||||
# step 1. However, since the gcc wrapper here *does* look in
|
||||
# native system directories (e.g., `/usr/lib'), it doesn't
|
||||
# prevent impurity in the things it builds (e.g., through
|
||||
# `-lncurses').
|
||||
stdenvLinuxBoot1 = (import ../stdenv/nix-linux) {
|
||||
stdenv = stdenvNative;
|
||||
pkgs = stdenvNativePkgs;
|
||||
glibc = stdenvLinuxGlibc;
|
||||
inherit genericStdenv gccWrapper;
|
||||
};
|
||||
|
||||
# 3) Now we can build packages that will have the Nix glibc.
|
||||
# 3) Now we can build packages that will link against the Nix
|
||||
# glibc. We are on thin ice here: the compiler used to build
|
||||
# these packages doesn't prevent impurity, so e.g. bash ends up
|
||||
# linking against `/lib/libncurses.so', but the glibc from step 1
|
||||
# *doesn't* search in `/lib' etc. So these programs won't work.
|
||||
stdenvLinuxBoot1Pkgs = allPackages {
|
||||
stdenv = stdenvLinuxBoot1;
|
||||
bootCurl = null;
|
||||
bootCurl = stdenvNativePkgs.curl;
|
||||
noSysDirs = true;
|
||||
};
|
||||
|
||||
# 4) However, since these packages are built by an native C compiler
|
||||
# and linker, they may well pick up impure references (e.g., bash
|
||||
# might end up linking against /lib/libncurses). So repeat, but
|
||||
# now use the Nix-built tools from step 2/3.
|
||||
# 4) Therefore we build a new standard environment which is the same
|
||||
# as the one in step 2, but with a gcc and binutils from step 3
|
||||
# merged in. Since these are pure (they don't search native
|
||||
# system directories), things built by this stdenv should be pure.
|
||||
stdenvLinuxBoot2 = (import ../stdenv/nix-linux) {
|
||||
stdenv = stdenvLinuxBoot1;
|
||||
pkgs = stdenvLinuxBoot1Pkgs;
|
||||
pkgs = stdenvNativePkgs // {
|
||||
inherit (stdenvLinuxBoot1Pkgs) gcc binutils;
|
||||
};
|
||||
glibc = stdenvLinuxGlibc;
|
||||
inherit genericStdenv gccWrapper;
|
||||
};
|
||||
|
||||
# 5) These packages should be pure.
|
||||
# 5) So these packages should be pure.
|
||||
stdenvLinuxBoot2Pkgs = allPackages {
|
||||
stdenv = stdenvLinuxBoot2;
|
||||
bootCurl = stdenvLinuxBoot1Pkgs.curl;
|
||||
bootCurl = stdenvNativePkgs.curl;
|
||||
};
|
||||
|
||||
# 6) So finally we can construct the Nix build environment.
|
||||
# 6) Finally we can construct the Nix build environment from the
|
||||
# packages from step 5.
|
||||
stdenvLinux = (import ../stdenv/nix-linux) {
|
||||
stdenv = stdenvLinuxBoot2;
|
||||
pkgs = stdenvLinuxBoot2Pkgs;
|
||||
@ -109,7 +117,20 @@
|
||||
} //
|
||||
{inherit (stdenvLinuxBoot2Pkgs)
|
||||
gzip bzip2 bash binutils coreutils diffutils findutils gawk gcc
|
||||
gnumake gnused gnutar gnugrep wget;
|
||||
gnumake gnused gnutar gnugrep curl;
|
||||
} //
|
||||
{glibc = stdenvLinuxGlibc;};
|
||||
|
||||
# In summary, we build gcc (and binutils) three times:
|
||||
# - in stdenvLinuxBoot1 (from stdenvNativePkgs); impure
|
||||
# - in stdenvLinuxBoot2 (from stdenvLinuxBoot1Pkgs); pure
|
||||
# - in stdenvLinux (from stdenvLinuxBoot2Pkgs); pure
|
||||
# The last one may be redundant, but its good for validation (since
|
||||
# the second one may use impure inputs). To reduce build time, we
|
||||
# could reduce the number of bootstrap stages inside each gcc build.
|
||||
# Right now there are 3 stages, so gcc is built 9 times!
|
||||
|
||||
# On the other hand, a validating build of glibc is a good idea (it
|
||||
# probably won't work right now due to --rpath madness).
|
||||
|
||||
}
|
||||
|
@ -2,15 +2,14 @@ let {
|
||||
system = "i686-linux";
|
||||
|
||||
stdenvs = (import ../../system/stdenvs.nix) {
|
||||
system = "i686-linux";
|
||||
inherit system;
|
||||
allPackages = import ../../system/all-packages-generic.nix;
|
||||
};
|
||||
|
||||
stdenv = stdenvs.stdenvLinux;
|
||||
stdenv = stdenvs.stdenvNix;
|
||||
|
||||
test = derivation {
|
||||
test = stdenv.mkDerivation {
|
||||
name = "simple-test";
|
||||
inherit system stdenv;
|
||||
builder = ./builder.sh;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user