summaryrefslogtreecommitdiffstats
path: root/pkgs/stdenv
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/adapters.nix40
-rw-r--r--pkgs/stdenv/cross/default.nix6
-rw-r--r--pkgs/stdenv/darwin/default.nix3265
-rw-r--r--pkgs/stdenv/freebsd/make-bootstrap-tools.nix17
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix2
-rw-r--r--pkgs/stdenv/generic/setup.sh389
-rw-r--r--pkgs/stdenv/linux/bootstrap-files/s390x-unknown-linux-gnu.nix18
-rw-r--r--pkgs/stdenv/linux/bootstrap-tools/glibc.nix2
-rw-r--r--pkgs/stdenv/linux/bootstrap-tools/musl.nix2
-rw-r--r--pkgs/stdenv/linux/default.nix23
-rw-r--r--pkgs/stdenv/linux/make-bootstrap-tools.nix5
-rw-r--r--pkgs/stdenv/linux/stdenv-bootstrap-tools.nix2
12 files changed, 2480 insertions, 1291 deletions
diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix
index 57c74fee233d..4289bcaeb991 100644
--- a/pkgs/stdenv/adapters.nix
+++ b/pkgs/stdenv/adapters.nix
@@ -261,25 +261,27 @@ rec {
in
overrideCC targetStdenv cc;
- useMoldLinker = stdenv: let
- bintools = stdenv.cc.bintools.override {
- extraBuildCommands = ''
- wrap ${stdenv.cc.bintools.targetPrefix}ld.mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold
- wrap ${stdenv.cc.bintools.targetPrefix}ld ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold
- '';
- };
- in stdenv.override (old: {
- allowedRequisites = null;
- cc = stdenv.cc.override { inherit bintools; };
- # gcc >12.1.0 supports '-fuse-ld=mold'
- # the wrap ld above in bintools supports gcc <12.1.0 and shouldn't harm >12.1.0
- # https://github.com/rui314/mold#how-to-use
- } // lib.optionalAttrs (stdenv.cc.isClang || (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "12")) {
- mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
- NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -fuse-ld=mold";
- });
- });
-
+ useMoldLinker = stdenv:
+ if stdenv.targetPlatform.isDarwin
+ then throw "Mold can't be used to emit Mach-O (Darwin) binaries"
+ else let
+ bintools = stdenv.cc.bintools.override {
+ extraBuildCommands = ''
+ wrap ${stdenv.cc.bintools.targetPrefix}ld.mold ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold
+ wrap ${stdenv.cc.bintools.targetPrefix}ld ${../build-support/bintools-wrapper/ld-wrapper.sh} ${pkgs.mold}/bin/ld.mold
+ '';
+ };
+ in stdenv.override (old: {
+ allowedRequisites = null;
+ cc = stdenv.cc.override { inherit bintools; };
+ # gcc >12.1.0 supports '-fuse-ld=mold'
+ # the wrap ld above in bintools supports gcc <12.1.0 and shouldn't harm >12.1.0
+ # https://github.com/rui314/mold#how-to-use
+ } // lib.optionalAttrs (stdenv.cc.isClang || (stdenv.cc.isGNU && lib.versionAtLeast stdenv.cc.version "12")) {
+ mkDerivationFromStdenv = extendMkDerivationArgs old (args: {
+ NIX_CFLAGS_LINK = toString (args.NIX_CFLAGS_LINK or "") + " -fuse-ld=mold";
+ });
+ });
/* Modify a stdenv so that it builds binaries optimized specifically
for the machine they are built on.
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
index 1cbbfeb6d202..6babb4020395 100644
--- a/pkgs/stdenv/cross/default.nix
+++ b/pkgs/stdenv/cross/default.nix
@@ -64,7 +64,7 @@ in lib.init bootStages ++ [
cc = if crossSystem.useiOSPrebuilt or false
then buildPackages.darwin.iosSdkPkgs.clang
else if crossSystem.useAndroidPrebuilt or false
- then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang
+ then buildPackages."androidndkPkgs_${crossSystem.androidNdkVersion}".clang
else if targetPlatform.isGhcjs
# Need to use `throw` so tryEval for splicing works, ugh. Using
# `null` or skipping the attribute would cause an eval failure
@@ -75,6 +75,10 @@ in lib.init bootStages ++ [
then buildPackages.llvmPackages.libcxxClang
else if crossSystem.useLLVM or false
then buildPackages.llvmPackages.clang
+ else if crossSystem.useZig or false
+ then buildPackages.zig.cc
+ else if crossSystem.useArocc or false
+ then buildPackages.arocc
else buildPackages.gcc;
extraNativeBuildInputs = old.extraNativeBuildInputs
diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix
index 5cc0b88bc709..dce0de939d5a 100644
--- a/pkgs/stdenv/darwin/default.nix
+++ b/pkgs/stdenv/darwin/default.nix
@@ -7,17 +7,20 @@
# See also the top comments of the Linux stdenv `../linux/default.nix` for a good overview of
# the bootstrap process and working with it.
-{ lib
-, localSystem
-, crossSystem
-, config
-, overlays
-, crossOverlays ? [ ]
+{
+ lib,
+ localSystem,
+ crossSystem,
+ config,
+ overlays,
+ crossOverlays ? [ ],
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
-, bootstrapFiles ? if localSystem.isAarch64 then
- import ./bootstrap-files/aarch64-apple-darwin.nix
- else
- import ./bootstrap-files/x86_64-apple-darwin.nix
+ bootstrapFiles ? (config.replaceBootstrapFiles or lib.id) (
+ if localSystem.isAarch64 then
+ import ./bootstrap-files/aarch64-apple-darwin.nix
+ else
+ import ./bootstrap-files/x86_64-apple-darwin.nix
+ ),
}:
assert crossSystem == localSystem;
@@ -34,12 +37,9 @@ let
];
isFromNixpkgs = pkg: !(isFromBootstrapFiles pkg);
- isFromBootstrapFiles =
- pkg: pkg.passthru.isFromBootstrapFiles or false;
- isBuiltByNixpkgsCompiler =
- pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc;
- isBuiltByBootstrapFilesCompiler =
- pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc;
+ isFromBootstrapFiles = pkg: pkg.passthru.isFromBootstrapFiles or false;
+ isBuiltByNixpkgsCompiler = pkg: isFromNixpkgs pkg && isFromNixpkgs pkg.stdenv.cc.cc;
+ isBuiltByBootstrapFilesCompiler = pkg: isFromNixpkgs pkg && isFromBootstrapFiles pkg.stdenv.cc.cc;
commonPreHook = ''
export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
@@ -48,84 +48,97 @@ let
unset SDKROOT
'';
- bootstrapTools = derivation ({
- inherit system;
+ bootstrapTools =
+ derivation (
+ {
+ inherit system;
- name = "bootstrap-tools";
- builder = "${bootstrapFiles.unpack}/bin/bash";
+ name = "bootstrap-tools";
+ builder = "${bootstrapFiles.unpack}/bin/bash";
- args = [
- "${bootstrapFiles.unpack}/bootstrap-tools-unpack.sh"
- bootstrapFiles.bootstrapTools
- ];
+ args = [
+ "${bootstrapFiles.unpack}/bootstrap-tools-unpack.sh"
+ bootstrapFiles.bootstrapTools
+ ];
- PATH = lib.makeBinPath [
- (placeholder "out")
- bootstrapFiles.unpack
- ];
+ PATH = lib.makeBinPath [
+ (placeholder "out")
+ bootstrapFiles.unpack
+ ];
- __impureHostDeps = commonImpureHostDeps;
- } // lib.optionalAttrs config.contentAddressedByDefault {
- __contentAddressed = true;
- outputHashAlgo = "sha256";
- outputHashMode = "recursive";
- }) // { passthru.isFromBootstrapFiles = true; };
+ __impureHostDeps = commonImpureHostDeps;
+ }
+ // lib.optionalAttrs config.contentAddressedByDefault {
+ __contentAddressed = true;
+ outputHashAlgo = "sha256";
+ outputHashMode = "recursive";
+ }
+ )
+ // {
+ passthru.isFromBootstrapFiles = true;
+ };
- stageFun = prevStage:
- { name, overrides ? (self: super: { }), extraNativeBuildInputs ? [ ], extraPreHook ? "" }:
+ stageFun =
+ prevStage:
+ {
+ name,
+ overrides ? (self: super: { }),
+ extraNativeBuildInputs ? [ ],
+ extraPreHook ? "",
+ }:
let
- cc = if prevStage.llvmPackages.clang-unwrapped == null
- then null else
- lib.makeOverridable (import ../../build-support/cc-wrapper) {
- name = "${name}-clang-wrapper";
-
- nativeTools = false;
- nativeLibc = false;
-
- expand-response-params = lib.optionalString
- (prevStage.stdenv.hasCC or false && prevStage.stdenv.cc != "/dev/null")
- prevStage.expand-response-params;
-
- extraPackages = [
- prevStage.llvmPackages.compiler-rt
- ];
-
- extraBuildCommands =
- let
- inherit (prevStage.llvmPackages) clang-unwrapped compiler-rt release_version;
- in
- ''
- function clangResourceRootIncludePath() {
- clangLib="$1/lib/clang"
- if (( $(ls "$clangLib" | wc -l) > 1 )); then
- echo "Multiple LLVM versions were found at "$clangLib", but there must only be one used when building the stdenv." >&2
- exit 1
- fi
- echo "$clangLib/$(ls -1 "$clangLib")/include"
- }
-
- rsrc="$out/resource-root"
- mkdir "$rsrc"
- ln -s "$(clangResourceRootIncludePath "${clang-unwrapped.lib}")" "$rsrc"
- ln -s "${compiler-rt.out}/lib" "$rsrc/lib"
- ln -s "${compiler-rt.out}/share" "$rsrc/share"
- echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
- '';
+ cc =
+ if prevStage.llvmPackages.clang-unwrapped == null then
+ null
+ else
+ lib.makeOverridable (import ../../build-support/cc-wrapper) {
+ name = "${name}-clang-wrapper";
+
+ nativeTools = false;
+ nativeLibc = false;
+
+ expand-response-params = lib.optionalString (
+ prevStage.stdenv.hasCC or false && prevStage.stdenv.cc != "/dev/null"
+ ) prevStage.expand-response-params;
+
+ extraPackages = [ prevStage.llvmPackages.compiler-rt ];
+
+ extraBuildCommands =
+ let
+ inherit (prevStage.llvmPackages) clang-unwrapped compiler-rt release_version;
+ in
+ ''
+ function clangResourceRootIncludePath() {
+ clangLib="$1/lib/clang"
+ if (( $(ls "$clangLib" | wc -l) > 1 )); then
+ echo "Multiple LLVM versions were found at "$clangLib", but there must only be one used when building the stdenv." >&2
+ exit 1
+ fi
+ echo "$clangLib/$(ls -1 "$clangLib")/include"
+ }
+
+ rsrc="$out/resource-root"
+ mkdir "$rsrc"
+ ln -s "$(clangResourceRootIncludePath "${clang-unwrapped.lib}")" "$rsrc"
+ ln -s "${compiler-rt.out}/lib" "$rsrc/lib"
+ ln -s "${compiler-rt.out}/share" "$rsrc/share"
+ echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
+ '';
- cc = prevStage.llvmPackages.clang-unwrapped;
- bintools = prevStage.darwin.binutils;
+ cc = prevStage.llvmPackages.clang-unwrapped;
+ bintools = prevStage.darwin.binutils;
- isClang = true;
- libc = prevStage.darwin.Libsystem;
- inherit (prevStage.llvmPackages) libcxx;
+ isClang = true;
+ libc = prevStage.darwin.Libsystem;
+ inherit (prevStage.llvmPackages) libcxx;
- inherit lib;
- inherit (prevStage) coreutils gnugrep;
+ inherit lib;
+ inherit (prevStage) coreutils gnugrep;
- stdenvNoCC = prevStage.ccWrapperStdenv;
- runtimeShell = prevStage.ccWrapperStdenv.shell;
- };
+ stdenvNoCC = prevStage.ccWrapperStdenv;
+ runtimeShell = prevStage.ccWrapperStdenv.shell;
+ };
bash = prevStage.bash or bootstrapTools;
@@ -139,22 +152,27 @@ let
inherit config;
extraBuildInputs = [ prevStage.darwin.CF ];
- extraNativeBuildInputs = extraNativeBuildInputs
- ++ [ prevStage.darwin.apple_sdk.sdkRoot ];
+ extraNativeBuildInputs = extraNativeBuildInputs ++ [ prevStage.darwin.apple_sdk.sdkRoot ];
- preHook = lib.optionalString (!isBuiltByNixpkgsCompiler bash) ''
- # Don't patch #!/interpreter because it leads to retained
- # dependencies on the bootstrapTools in the final stdenv.
- dontPatchShebangs=1
- '' + ''
- ${commonPreHook}
- ${extraPreHook}
- '' + lib.optionalString (prevStage.darwin ? locale) ''
- export PATH_LOCALE=${prevStage.darwin.locale}/share/locale
- '';
+ preHook =
+ lib.optionalString (!isBuiltByNixpkgsCompiler bash) ''
+ # Don't patch #!/interpreter because it leads to retained
+ # dependencies on the bootstrapTools in the final stdenv.
+ dontPatchShebangs=1
+ ''
+ + ''
+ ${commonPreHook}
+ ${extraPreHook}
+ ''
+ + lib.optionalString (prevStage.darwin ? locale) ''
+ export PATH_LOCALE=${prevStage.darwin.locale}/share/locale
+ '';
shell = bash + "/bin/bash";
- initialPath = [ bash bootstrapTools ];
+ initialPath = [
+ bash
+ bootstrapTools
+ ];
fetchurlBoot = import ../../build-support/fetchurl {
inherit lib;
@@ -171,11 +189,14 @@ let
# Using the bootstrap tools curl for fetchers allows the stdenv bootstrap to avoid
# having a dependency on curl, allowing curl to be updated without triggering a
# new stdenv bootstrap on Darwin.
- overrides = self: super: (overrides self super) // {
- fetchurl = thisStdenv.fetchurlBoot;
- fetchpatch = super.fetchpatch.override { inherit (self) fetchurl; };
- fetchzip = super.fetchzip.override { inherit (self) fetchurl; };
- };
+ overrides =
+ self: super:
+ (overrides self super)
+ // {
+ fetchurl = thisStdenv.fetchurlBoot;
+ fetchpatch = super.fetchpatch.override { inherit (self) fetchurl; };
+ fetchzip = super.fetchzip.override { inherit (self) fetchurl; };
+ };
};
in
@@ -184,532 +205,783 @@ let
stdenv = thisStdenv;
};
in
- assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
+assert bootstrapTools.passthru.isFromBootstrapFiles or false; # sanity check
[
- ({}: {
- __raw = true;
-
- cctools = true;
- ld64 = true;
-
- coreutils = null;
- gnugrep = null;
-
- pbzx = null;
- cpio = null;
-
- darwin = {
- apple_sdk.sdkRoot = null;
- binutils = null;
- binutils-unwrapped = null;
- print-reexports = null;
- rewrite-tbd = null;
- sigtool = null;
- CF = null;
- Libsystem = null;
- };
+ (
+ { }:
+ {
+ __raw = true;
- llvmPackages = {
- clang-unwrapped = null;
- libllvm = null;
- libcxx = null;
- compiler-rt = null;
- };
- })
+ cctools = true;
+ ld64 = true;
- # Create a stage with the bootstrap tools. This will be used to build the subsequent stages and
- # build up the standard environment.
- #
- # Note: Each stage depends only on the the packages in `prevStage`. If a package is not to be
- # rebuilt, it should be passed through by inheriting it.
- (prevStage: stageFun prevStage {
- name = "bootstrap-stage0";
-
- overrides = self: super: {
- # We thread stage0's stdenv through under this name so downstream stages
- # can use it for wrapping gcc too. This way, downstream stages don't need
- # to refer to this stage directly, which violates the principle that each
- # stage should only access the stage that came before it.
- ccWrapperStdenv = self.stdenv;
-
- bash = bootstrapTools // {
- shellPath = "/bin/bash";
- };
+ coreutils = null;
+ gnugrep = null;
- coreutils = bootstrapTools;
- cpio = bootstrapTools;
- gnugrep = bootstrapTools;
- pbzx = bootstrapTools;
-
- cctools = super.stdenv.mkDerivation {
- pname = "bootstrap-stage0-cctools";
- version = "boot";
-
- buildCommand = ''
- declare -a cctools=(
- ar
- bitcode_strip
- check_dylib
- checksyms
- cmpdylib
- codesign_allocate
- ctf_insert
- depinfo
- diagtest
- gas
- gprof
- install_name_tool
- libtool
- lipo
- mtoc
- mtor
- nm
- nmedit
- otool
- pagestuff
- ranlib
- redo_prebinding
- seg_addr_table
- seg_hack
- segedit
- size
- strings
- strip
- vtool
- )
-
- mkdir -p "$out/bin"
- for tool in "''${cctools[@]}"; do
- toolsrc="${bootstrapTools}/bin/$tool"
- if [ -e "$toolsrc" ]; then
- ln -s "$toolsrc" "$out/bin"
- fi
- done
-
- # Copy only the required headers to avoid accidentally linking headers that belong to other packages,
- # which can cause problems when building Libsystem in the source-based SDK.
- declare -a machohdrs=(
- arch.h
- fat.h
- fixup-chains.h
- getsect.h
- ldsyms.h
- loader.h
- nlist.h
- ranlib.h
- reloc.h
- stab.h
- swap.h
- arm
- arm64
- hppa
- i386
- i860
- m68k
- m88k
- ppc
- sparc
- x86_64
- )
-
- mkdir -p "$out/include/mach-o"
- for header in "''${machohdrs[@]}"; do
- machosrc="${bootstrapTools}/include-Libsystem/mach-o/$header"
- if [ -e "$machosrc" ]; then
- cp -r "$machosrc" "$out/include/mach-o/$header"
- fi
- done
- '';
+ pbzx = null;
+ cpio = null;
- passthru = {
- isFromBootstrapFiles = true;
- targetPrefix = "";
- };
+ darwin = {
+ apple_sdk.sdkRoot = null;
+ binutils = null;
+ binutils-unwrapped = null;
+ print-reexports = null;
+ rewrite-tbd = null;
+ sigtool = null;
+ CF = null;
+ Libsystem = null;
};
- ld64 = bootstrapTools // {
- targetPrefix = "";
- version = "boot";
+ llvmPackages = {
+ clang-unwrapped = null;
+ libllvm = null;
+ libcxx = null;
+ compiler-rt = null;
};
+ }
+ )
- darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
- # Prevent CF from being propagated to the initial stdenv. Packages that require it
- # will have to manually add it to their build inputs.
- CF = null;
-
- binutils = super.wrapBintoolsWith {
- name = "bootstrap-stage0-binutils-wrapper";
-
- nativeTools = false;
- nativeLibc = false;
-
- expand-response-params = "";
- libc = selfDarwin.Libsystem;
-
- inherit lib;
- inherit (self) stdenvNoCC coreutils gnugrep;
- runtimeShell = self.stdenvNoCC.shell;
+ # Create a stage with the bootstrap tools. This will be used to build the subsequent stages and
+ # build up the standard environment.
+ #
+ # Note: Each stage depends only on the the packages in `prevStage`. If a package is not to be
+ # rebuilt, it should be passed through by inheriting it.
+ (
+ prevStage:
+ stageFun prevStage {
+ name = "bootstrap-stage0";
- bintools = selfDarwin.binutils-unwrapped;
+ overrides = self: super: {
+ # We thread stage0's stdenv through under this name so downstream stages
+ # can use it for wrapping gcc too. This way, downstream stages don't need
+ # to refer to this stage directly, which violates the principle that each
+ # stage should only access the stage that came before it.
+ ccWrapperStdenv = self.stdenv;
+
+ bash = bootstrapTools // {
+ shellPath = "/bin/bash";
+ };
- # Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly.
- # This can be dropped once the bootstrap tools cctools has been updated to 1010.6.
- extraBuildCommands = ''
- echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook
+ coreutils = bootstrapTools;
+ cpio = bootstrapTools;
+ gnugrep = bootstrapTools;
+ pbzx = bootstrapTools;
- export signingUtils=${selfDarwin.signingUtils}
+ cctools = super.stdenv.mkDerivation {
+ pname = "bootstrap-stage0-cctools";
+ version = "boot";
- wrap \
- install_name_tool ${../../build-support/bintools-wrapper/darwin-install_name_tool-wrapper.sh} \
- "${selfDarwin.binutils-unwrapped}/bin/install_name_tool"
+ buildCommand = ''
+ declare -a cctools=(
+ ar
+ bitcode_strip
+ check_dylib
+ checksyms
+ cmpdylib
+ codesign_allocate
+ ctf_insert
+ depinfo
+ diagtest
+ gas
+ gprof
+ install_name_tool
+ libtool
+ lipo
+ mtoc
+ mtor
+ nm
+ nmedit
+ otool
+ pagestuff
+ ranlib
+ redo_prebinding
+ seg_addr_table
+ seg_hack
+ segedit
+ size
+ strings
+ strip
+ vtool
+ )
+
+ mkdir -p "$out/bin"
+ for tool in "''${cctools[@]}"; do
+ toolsrc="${bootstrapTools}/bin/$tool"
+ if [ -e "$toolsrc" ]; then
+ ln -s "$toolsrc" "$out/bin"
+ fi
+ done
- wrap \
- strip ${../../build-support/bintools-wrapper/darwin-strip-wrapper.sh} \
- "${selfDarwin.binutils-unwrapped}/bin/strip"
+ # Copy only the required headers to avoid accidentally linking headers that belong to other packages,
+ # which can cause problems when building Libsystem in the source-based SDK.
+ declare -a machohdrs=(
+ arch.h
+ fat.h
+ fixup-chains.h
+ getsect.h
+ ldsyms.h
+ loader.h
+ nlist.h
+ ranlib.h
+ reloc.h
+ stab.h
+ swap.h
+ arm
+ arm64
+ hppa
+ i386
+ i860
+ m68k
+ m88k
+ ppc
+ sparc
+ x86_64
+ )
+
+ mkdir -p "$out/include/mach-o"
+ for header in "''${machohdrs[@]}"; do
+ machosrc="${bootstrapTools}/include-Libsystem/mach-o/$header"
+ if [ -e "$machosrc" ]; then
+ cp -r "$machosrc" "$out/include/mach-o/$header"
+ fi
+ done
'';
- };
- binutils-unwrapped = (superDarwin.binutils-unwrapped.overrideAttrs (old: {
- version = "boot";
- passthru = (old.passthru or { }) // {
+ passthru = {
isFromBootstrapFiles = true;
+ targetPrefix = "";
};
- })).override { enableManpages = false; };
+ };
- locale = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-locale";
- buildCommand = ''
- mkdir -p $out/share/locale
- '';
+ ld64 = bootstrapTools // {
+ targetPrefix = "";
+ version = "boot";
};
- print-reexports = bootstrapTools;
+ darwin = super.darwin.overrideScope (
+ selfDarwin: superDarwin:
+ {
+ # Prevent CF from being propagated to the initial stdenv. Packages that require it
+ # will have to manually add it to their build inputs.
+ CF = null;
- rewrite-tbd = bootstrapTools;
+ binutils = super.wrapBintoolsWith {
+ name = "bootstrap-stage0-binutils-wrapper";
- sigtool = bootstrapTools;
- } // lib.optionalAttrs (! useAppleSDKLibs) {
- Libsystem = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-Libsystem";
- buildCommand = ''
- mkdir -p $out
+ nativeTools = false;
+ nativeLibc = false;
- cp -r ${selfDarwin.darwin-stubs}/usr/lib $out/lib
- chmod -R +w $out/lib
- substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system
+ expand-response-params = "";
+ libc = selfDarwin.Libsystem;
- ln -s libSystem.B.tbd $out/lib/libSystem.tbd
+ inherit lib;
+ inherit (self) stdenvNoCC coreutils gnugrep;
+ runtimeShell = self.stdenvNoCC.shell;
- for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
- ln -s libSystem.tbd $out/lib/lib$name.tbd
- done
+ bintools = selfDarwin.binutils-unwrapped;
- ln -s ${bootstrapTools}/lib/*.o $out/lib
+ # Bootstrap tools cctools needs the hook and wrappers to make sure things are signed properly.
+ # This can be dropped once the bootstrap tools cctools has been updated to 1010.6.
+ extraBuildCommands = ''
+ echo 'source ${selfDarwin.postLinkSignHook}' >> $out/nix-support/post-link-hook
- ln -s ${bootstrapTools}/lib/libresolv.9.dylib $out/lib
- ln -s libresolv.9.dylib $out/lib/libresolv.dylib
+ export signingUtils=${selfDarwin.signingUtils}
- ln -s ${bootstrapTools}/include-Libsystem $out/include
- '';
- passthru.isFromBootstrapFiles = true;
- };
- });
-
- llvmPackages = super.llvmPackages // (
- let
- tools = super.llvmPackages.tools.extend (selfTools: _: {
- libclang = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-clang";
- version = "boot";
- outputs = [ "out" "lib" ];
- buildCommand = ''
- mkdir -p $out/lib
- ln -s $out $lib
- ln -s ${bootstrapTools}/bin $out/bin
- ln -s ${bootstrapTools}/lib/clang $out/lib
- ln -s ${bootstrapTools}/include $out
- '';
- passthru = {
- isFromBootstrapFiles = true;
- hardeningUnsupportedFlags = [
- "fortify3"
- "stackclashprotection"
- "zerocallusedregs"
- ];
- };
- };
- libllvm = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-llvm";
- outputs = [ "out" "lib" ];
- buildCommand = ''
- mkdir -p $out/bin $out/lib
- ln -s $out $lib
- for tool in ${toString super.darwin.binutils-unwrapped.llvm_cmds}; do
- cctoolsTool=''${tool//-/_}
- toolsrc="${bootstrapTools}/bin/$cctoolsTool"
- if [ -e "$toolsrc" ]; then
- ln -s "$toolsrc" $out/bin/llvm-$tool
- fi
- done
- ln -s ${bootstrapTools}/bin/dsymutil $out/bin/dsymutil
- ln -s ${bootstrapTools}/lib/libLLVM* $out/lib
+ wrap \
+ install_name_tool ${../../build-support/bintools-wrapper/darwin-install_name_tool-wrapper.sh} \
+ "${selfDarwin.binutils-unwrapped}/bin/install_name_tool"
+
+ wrap \
+ strip ${../../build-support/bintools-wrapper/darwin-strip-wrapper.sh} \
+ "${selfDarwin.binutils-unwrapped}/bin/strip"
'';
- passthru.isFromBootstrapFiles = true;
};
- });
- libraries = super.llvmPackages.libraries.extend (_: _: {
- libcxx = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-libcxx";
+
+ binutils-unwrapped =
+ (superDarwin.binutils-unwrapped.overrideAttrs (old: {
+ version = "boot";
+ passthru = (old.passthru or { }) // {
+ isFromBootstrapFiles = true;
+ };
+ })).override
+ { enableManpages = false; };
+
+ locale = self.stdenv.mkDerivation {
+ name = "bootstrap-stage0-locale";
buildCommand = ''
- mkdir -p $out/lib $out/include
- ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib
- ln -s ${bootstrapTools}/include/c++ $out/include
+ mkdir -p $out/share/locale
'';
- passthru = {
- isLLVM = true;
- isFromBootstrapFiles = true;
- };
};
- compiler-rt = self.stdenv.mkDerivation {
- name = "bootstrap-stage0-compiler-rt";
+
+ print-reexports = bootstrapTools;
+
+ rewrite-tbd = bootstrapTools;
+
+ sigtool = bootstrapTools;
+ }
+ // lib.optionalAttrs (!useAppleSDKLibs) {
+ Libsystem = self.stdenv.mkDerivation {
+ name = "bootstrap-stage0-Libsystem";
buildCommand = ''
- mkdir -p $out/lib $out/share
- ln -s ${bootstrapTools}/lib/libclang_rt* $out/lib
- ln -s ${bootstrapTools}/lib/darwin $out/lib
+ mkdir -p $out
+
+ cp -r ${selfDarwin.darwin-stubs}/usr/lib $out/lib
+ chmod -R +w $out/lib
+ substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system
+
+ ln -s libSystem.B.tbd $out/lib/libSystem.tbd
+
+ for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
+ ln -s libSystem.tbd $out/lib/lib$name.tbd
+ done
+
+ ln -s ${bootstrapTools}/lib/*.o $out/lib
+
+ ln -s ${bootstrapTools}/lib/libresolv.9.dylib $out/lib
+ ln -s libresolv.9.dylib $out/lib/libresolv.dylib
+
+ ln -s ${bootstrapTools}/include-Libsystem $out/include
'';
passthru.isFromBootstrapFiles = true;
};
- });
- in
- { inherit tools libraries; } // tools // libraries
- );
- };
+ }
+ );
- extraPreHook = ''
- stripDebugFlags="-S" # llvm-strip does not support "-p" for Mach-O
- '';
- })
+ llvmPackages =
+ super.llvmPackages
+ // (
+ let
+ tools = super.llvmPackages.tools.extend (
+ selfTools: _: {
+ libclang = self.stdenv.mkDerivation {
+ name = "bootstrap-stage0-clang";
+ version = "boot";
+ outputs = [
+ "out"
+ "lib"
+ ];
+ buildCommand = ''
+ mkdir -p $out/lib
+ ln -s $out $lib
+ ln -s ${bootstrapTools}/bin $out/bin
+ ln -s ${bootstrapTools}/lib/clang $out/lib
+ ln -s ${bootstrapTools}/include $out
+ '';
+ passthru = {
+ isFromBootstrapFiles = true;
+ hardeningUnsupportedFlags = [
+ "fortify3"
+ "shadowstack"
+ "stackclashprotection"
+ "zerocallusedregs"
+ ];
+ };
+ };
+ libllvm = self.stdenv.mkDerivation {
+ name = "bootstrap-stage0-llvm";
+ outputs = [
+ "out"
+ "lib"
+ ];
+ buildCommand = ''
+ mkdir -p $out/bin $out/lib
+ ln -s $out $lib
+ for tool in ${toString super.darwin.binutils-unwrapped.llvm_cmds}; do
+ cctoolsTool=''${tool//-/_}
+ toolsrc="${bootstrapTools}/bin/$cctoolsTool"
+ if [ -e "$toolsrc" ]; then
+ ln -s "$toolsrc" $out/bin/llvm-$tool
+ fi
+ done
+ ln -s ${bootstrapTools}/bin/dsymutil $out/bin/dsymutil
+ ln -s ${bootstrapTools}/lib/libLLVM* $out/lib