new darwin stdenv

This commit is contained in:
Eric Seidel 2015-02-03 14:04:19 -08:00
parent 6f7632a7bd
commit 92188d9d17
3 changed files with 200 additions and 55 deletions

View File

@ -1,43 +1,141 @@
{ stdenv, pkgs, config { system ? builtins.currentSystem
, haveLibCxx ? true , allPackages ? import ../../top-level/all-packages.nix
, useClang33 ? true }: , platform ? null
, config ? {}
}:
import ../generic rec { rec {
inherit config; allPackages = import ../../top-level/all-packages.nix;
preHook = bootstrapTools = derivation {
'' inherit system;
export NIX_ENFORCE_PURITY=
export NIX_IGNORE_LD_THROUGH_GCC=1 name = "trivial-bootstrap-tools";
export NIX_DONT_SET_RPATH=1 builder = "/bin/sh";
export NIX_NO_SELF_RPATH=1 args = [ ./trivialBootstrap.sh ];
${import ./prehook.nix}
mkdir = "/bin/mkdir";
ln = "/bin/ln";
};
# The simplest stdenv possible to run fetchadc and get the Apple command-line tools
stage0 = rec {
fetchurl = import ../../build-support/fetchurl {
inherit stdenv;
curl = bootstrapTools;
};
stdenv = import ../generic {
inherit system config;
name = "stdenv-darwin-boot-0";
shell = "/bin/bash";
initialPath = [ bootstrapTools ];
fetchurlBoot = fetchurl;
cc = "/no-such-path";
};
};
buildTools = import ../../os-specific/darwin/command-line-tools {
inherit (stage0) stdenv fetchurl;
xar = bootstrapTools;
gzip = bootstrapTools;
cpio = bootstrapTools;
};
preHook = ''
export NIX_IGNORE_LD_THROUGH_GCC=1
export NIX_DONT_SET_RPATH=1
export NIX_NO_SELF_RPATH=1
dontFixLibtool=1
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
xargsFlags=" "
export MACOSX_DEPLOYMENT_TARGET=10.7
export SDKROOT=
export SDKROOT_X=/ # FIXME: impure!
export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT_X/usr/include -F$SDKROOT_X/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
export NIX_LDFLAGS_AFTER+=" -L$SDKROOT_X/usr/lib"
export CMAKE_OSX_ARCHITECTURES=x86_64
'';
# A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
stage1 = rec {
nativePrefix = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
stdenv = import ../generic {
name = "stdenv-darwin-boot-1";
inherit system config;
inherit (stage0.stdenv) shell initialPath fetchurlBoot;
preHook = preHook + "\n" + ''
export NIX_LDFLAGS_AFTER+=" -L/usr/lib"
export NIX_ENFORCE_PURITY=
export NIX_CFLAGS_COMPILE+=" -isystem ${nativePrefix}/include/c++/v1 -stdlib=libc++"
export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,${nativePrefix}/lib"
'';
cc = import ../../build-support/cc-wrapper {
nativeTools = true;
nativePrefix = nativePrefix;
nativeLibc = true;
stdenv = stage0.stdenv;
shell = "/bin/bash";
cc = {
name = "clang-9.9.9";
cc = "/usr";
outPath = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
};
};
};
pkgs = allPackages {
inherit system platform;
bootStdenv = stdenv;
};
};
stage2 = rec {
stdenv = import ../generic {
name = "stdenv-darwin-boot-2";
inherit system config;
inherit (stage1.stdenv) shell fetchurlBoot preHook cc;
initialPath = [ stage1.pkgs.xz ] ++ stage1.stdenv.initialPath;
};
pkgs = allPackages {
inherit system platform;
bootStdenv = stdenv;
};
};
# Use stage1 to build a whole set of actual tools so we don't have to rely on the Apple prebuilt ones or
# the ugly symlinked bootstrap tools anymore.
stage3 = with stage2; import ../generic {
name = "stdenv-darwin-boot-3";
inherit system config;
inherit (stdenv) fetchurlBoot;
initialPath = (import ../common-path.nix) { inherit pkgs; };
preHook = preHook + "\n" + ''
export NIX_ENFORCE_PURITY=1
''; '';
initialPath = (import ../common-path.nix) {pkgs = pkgs;}; cc = import ../../build-support/cc-wrapper {
inherit stdenv;
nativeTools = false;
nativeLibc = true;
binutils = pkgs.darwin.cctools_native;
cc = pkgs.llvmPackages.clang;
coreutils = pkgs.coreutils;
shell = "${pkgs.bash}/bin/bash";
};
system = stdenv.system; extraBuildInputs = [ pkgs.libcxx ];
cc = import ../../build-support/cc-wrapper { shell = "${pkgs.bash}/bin/bash";
nativeTools = false;
nativeLibc = true;
inherit stdenv;
extraPackages = stdenv.lib.optional haveLibCxx pkgs.libcxx;
binutils = import ../../build-support/native-darwin-cctools-wrapper {inherit stdenv;};
cc = if useClang33 then pkgs.clang_33.cc else pkgs.clang.cc;
coreutils = pkgs.coreutils;
shell = pkgs.bash + "/bin/sh";
}; };
shell = pkgs.bash + "/bin/sh"; stdenvDarwin = stage3;
fetchurlBoot = stdenv.fetchurlBoot;
overrides = pkgs_: {
inherit cc;
inherit (cc) binutils;
inherit (pkgs)
gzip bzip2 xz bash coreutils diffutils findutils gawk
gnumake gnused gnutar gnugrep gnupatch perl libcxx libcxxabi;
};
} }

View File

@ -0,0 +1,66 @@
# Building bootstrap tools
echo Building the trivial bootstrap environment...
$mkdir -p $out/bin
$ln -s $ln $out/bin/ln
PATH=$out/bin/
cd $out/bin
ln -s $mkdir
ln -s /bin/sh
ln -s /bin/cp
ln -s /bin/mv
ln -s /bin/rm
ln -s /bin/ls
ln -s /bin/ps
ln -s /bin/cat
ln -s /bin/bash
ln -s /bin/echo
ln -s /bin/expr
ln -s /bin/test
ln -s /bin/date
ln -s /bin/chmod
ln -s /bin/rmdir
ln -s /bin/sleep
ln -s /bin/hostname
ln -s /usr/bin/id
ln -s /usr/bin/od
ln -s /usr/bin/tr
ln -s /usr/bin/wc
ln -s /usr/bin/cut
ln -s /usr/bin/cmp
ln -s /usr/bin/sed
ln -s /usr/bin/tar
ln -s /usr/bin/xar
ln -s /usr/bin/awk
ln -s /usr/bin/env
ln -s /usr/bin/tee
ln -s /usr/bin/comm
ln -s /usr/bin/cpio
ln -s /usr/bin/curl
ln -s /usr/bin/find
ln -s /usr/bin/grep
ln -s /usr/bin/gzip
ln -s /usr/bin/head
ln -s /usr/bin/tail
ln -s /usr/bin/sort
ln -s /usr/bin/uniq
ln -s /usr/bin/less
ln -s /usr/bin/true
ln -s /usr/bin/diff
ln -s /usr/bin/egrep
ln -s /usr/bin/fgrep
ln -s /usr/bin/patch
ln -s /usr/bin/uname
ln -s /usr/bin/touch
ln -s /usr/bin/split
ln -s /usr/bin/xargs
ln -s /usr/bin/which
ln -s /usr/bin/install
ln -s /usr/bin/basename
ln -s /usr/bin/dirname
ln -s /usr/bin/readlink

View File

@ -33,30 +33,11 @@ rec {
pkgs = stdenvNativePkgs; pkgs = stdenvNativePkgs;
}; };
stdenvDarwin = import ./darwin {
inherit config;
stdenv = stdenvNative;
pkgs = stdenvNativePkgs;
};
stdenvDarwinNaked = import ./darwin {
inherit config;
stdenv = stdenvNative;
pkgs = stdenvNativePkgs;
haveLibCxx = false;
};
stdenvDarwin33 = import ./darwin {
inherit config;
stdenv = stdenvNative;
pkgs = stdenvNativePkgs;
useClang33 = true;
};
# Linux standard environment. # Linux standard environment.
stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux; stdenvLinux = (import ./linux { inherit system allPackages platform config lib; }).stdenvLinux;
# Darwin standard environment.
stdenvDarwin = (import ./darwin { inherit system allPackages platform config;}).stdenvDarwin;
# Select the appropriate stdenv for the platform `system'. # Select the appropriate stdenv for the platform `system'.
stdenv = stdenv =