7 , bootstrapLlvmVersion ? "11.1.0"
8 # Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
9 , bootstrapFiles ? if localSystem.isAarch64 then
11 fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
12 url = "http://tarballs.nixos.org/stdenv-darwin/aarch64/20acd4c4f14040485f40e55c0a76c186aa8ca4f3/${file}";
13 inherit (localSystem) system;
14 inherit sha256 executable;
17 sh = fetch { file = "sh"; sha256 = "17m3xrlbl99j3vm7rzz3ghb47094dyddrbvs2a6jalczvmx7spnj"; };
18 bzip2 = fetch { file = "bzip2"; sha256 = "1khs8s5klf76plhlvlc1ma838r8pc1qigk9f5bdycwgbn0nx240q"; };
19 mkdir = fetch { file = "mkdir"; sha256 = "1m9nk90paazl93v43myv2ay68c1arz39pqr7lk5ddbgb177hgg8a"; };
20 cpio = fetch { file = "cpio"; sha256 = "17pxq61yjjvyd738fy9f392hc9cfzkl612sdr9rxr3v0dgvm8y09"; };
21 tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1v2332k33akm6mrm4bj749rxnnmc2pkbgcslmd0bbkf76bz2ildy"; executable = false; };
25 fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
26 url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/c253216595572930316f2be737dc288a1da22558/${file}";
27 inherit (localSystem) system;
28 inherit sha256 executable;
31 sh = fetch { file = "sh"; sha256 = "sha256-igMAVEfumFv/LUNTGfNi2nSehgTNIP4Sg+f3L7u6SMA="; };
32 bzip2 = fetch { file = "bzip2"; sha256 = "sha256-K3rhkJZipudT1Jgh+l41Y/fNsMkrPtiAsNRDha/lpZI="; };
33 mkdir = fetch { file = "mkdir"; sha256 = "sha256-VddFELwLDJGNADKB1fWwWPBtIAlEUgJv2hXRmC4NEeM="; };
34 cpio = fetch { file = "cpio"; sha256 = "sha256-SWkwvLaFyV44kLKL2nx720SvcL4ej/p2V/bX3uqAGO0="; };
35 tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "sha256-kRC/bhCmlD4L7KAvJQgcukk7AinkMz4IwmG1rqlh5tA="; executable = false; };
39 assert crossSystem == localSystem;
42 inherit (localSystem) system;
44 useAppleSDKLibs = localSystem.isAarch64;
45 haveKRB5 = localSystem.isx86_64;
47 # final toolchain is injected into llvmPackages_${finalLlvmVersion}
48 finalLlvmVersion = lib.versions.major bootstrapLlvmVersion;
49 finalLlvmPackages = "llvmPackages_${finalLlvmVersion}";
51 commonImpureHostDeps = [
53 "/usr/lib/libSystem.B.dylib"
54 "/usr/lib/system/libunc.dylib" # This dependency is "hidden", so our scanning code doesn't pick it up
60 export NIX_ENFORCE_NO_NATIVE=''${NIX_ENFORCE_NO_NATIVE-1}
61 export NIX_ENFORCE_PURITY=''${NIX_ENFORCE_PURITY-1}
62 export NIX_IGNORE_LD_THROUGH_GCC=1
65 stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
68 bootstrapTools = derivation ({
71 name = "bootstrap-tools";
72 builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles
73 args = if localSystem.isAarch64 then [ ./unpack-bootstrap-tools-aarch64.sh ] else [ ./unpack-bootstrap-tools.sh ];
75 inherit (bootstrapFiles) mkdir bzip2 cpio tarball;
77 __impureHostDeps = commonImpureHostDeps;
78 } // lib.optionalAttrs config.contentAddressedByDefault {
79 __contentAddressed = true;
80 outputHashAlgo = "sha256";
81 outputHashMode = "recursive";
84 stageFun = step: last: { shell ? "${bootstrapTools}/bin/bash"
85 , overrides ? (self: super: { })
87 , extraNativeBuildInputs
90 , allowedRequisites ? null
93 name = "bootstrap-stage${toString step}";
95 buildPackages = lib.optionalAttrs (last ? stdenv) {
96 inherit (last) stdenv;
99 doSign = localSystem.isAarch64 && last != null;
100 doUpdateAutoTools = localSystem.isAarch64 && last != null;
101 inherit (last.pkgs) runCommandLocal;
103 mkExtraBuildCommands = cc: ''
104 rsrc="$out/resource-root"
106 ln -s "${cc.lib or cc}/lib/clang/${cc.version}/include" "$rsrc"
107 ln -s "${last.pkgs."${finalLlvmPackages}".compiler-rt.out}/lib" "$rsrc/lib"
108 echo "-resource-dir=$rsrc" >> $out/nix-support/cc-cflags
111 mkCC = overrides: import ../../build-support/cc-wrapper (
114 inherit (last) stdenvNoCC;
118 inherit buildPackages libcxx;
119 inherit (last.pkgs) coreutils gnugrep;
120 bintools = last.pkgs.darwin.binutils;
121 libc = last.pkgs.darwin.Libsystem;
123 cc = last.pkgs."${finalLlvmPackages}".clang-unwrapped;
124 }; in args // (overrides args)
127 cc = if last == null then "/dev/null" else
130 last.pkgs."${finalLlvmPackages}".libcxxabi
131 last.pkgs."${finalLlvmPackages}".compiler-rt
133 extraBuildCommands = mkExtraBuildCommands cc;
136 ccNoLibcxx = if last == null then "/dev/null" else
140 last.pkgs."${finalLlvmPackages}".compiler-rt
142 extraBuildCommands = ''
143 echo "-rtlib=compiler-rt" >> $out/nix-support/cc-cflags
144 echo "-B${last.pkgs."${finalLlvmPackages}".compiler-rt}/lib" >> $out/nix-support/cc-cflags
145 echo "-nostdlib++" >> $out/nix-support/cc-cflags
146 '' + mkExtraBuildCommands cc;
149 thisStdenv = import ../generic {
150 name = "${name}-stdenv-darwin";
152 inherit config shell extraBuildInputs;
154 extraNativeBuildInputs = extraNativeBuildInputs ++ lib.optionals doUpdateAutoTools [
155 last.pkgs.updateAutotoolsGnuConfigScriptsHook
159 allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [
160 cc.expand-response-params
162 ] ++ lib.optionals doUpdateAutoTools [
163 last.pkgs.updateAutotoolsGnuConfigScriptsHook
165 ] ++ lib.optionals doSign [
166 last.pkgs.darwin.postLinkSignHook
167 last.pkgs.darwin.sigtool
168 last.pkgs.darwin.signingUtils
171 buildPlatform = localSystem;
172 hostPlatform = localSystem;
173 targetPlatform = localSystem;
177 preHook = lib.optionalString (shell == "${bootstrapTools}/bin/bash") ''
178 # Don't patch #!/interpreter because it leads to retained
179 # dependencies on the bootstrapTools in the final stdenv.
185 initialPath = [ bootstrapTools ];
187 fetchurlBoot = import ../../build-support/fetchurl {
189 stdenvNoCC = stage0.stdenv;
190 curl = bootstrapTools;
193 # The stdenvs themselves don't use mkDerivation, so I need to specify this here
194 __stdenvImpureHostDeps = commonImpureHostDeps;
195 __extraImpureHostDeps = commonImpureHostDeps;
197 overrides = self: super: (overrides self super) // {
199 fetchurl = thisStdenv.fetchurlBoot;
205 inherit config overlays;
209 stage0 = stageFun 0 null {
210 overrides = self: super: with stage0; {
211 coreutils = stdenv.mkDerivation {
212 name = "bootstrap-stage0-coreutils";
215 ln -s ${bootstrapTools}/bin $out/bin
219 gnugrep = stdenv.mkDerivation {
220 name = "bootstrap-stage0-gnugrep";
223 ln -s ${bootstrapTools}/bin $out/bin
227 pbzx = self.runCommandLocal "bootstrap-stage0-pbzx" { } ''
229 ln -s ${bootstrapTools}/bin/pbzx $out/bin
232 cpio = self.runCommandLocal "bootstrap-stage0-cpio" { } ''
234 ln -s ${bootstrapFiles.cpio} $out/bin/cpio
237 darwin = super.darwin.overrideScope (selfDarwin: superDarwin: {
238 darwin-stubs = superDarwin.darwin-stubs.override { inherit (self) stdenvNoCC fetchurl; };
241 name = "bootstrap-stage0-dyld";
244 ln -s ${bootstrapTools}/lib $out/lib
245 ln -s ${bootstrapTools}/include $out/include
249 sigtool = self.runCommandLocal "bootstrap-stage0-sigtool" { } ''
251 ln -s ${bootstrapTools}/bin/sigtool $out/bin
252 ln -s ${bootstrapTools}/bin/codesign $out/bin
255 print-reexports = self.runCommandLocal "bootstrap-stage0-print-reexports" { } ''
257 ln -s ${bootstrapTools}/bin/print-reexports $out/bin
260 rewrite-tbd = self.runCommandLocal "bootstrap-stage0-rewrite-tbd" { } ''
262 ln -s ${bootstrapTools}/bin/rewrite-tbd $out/bin
265 binutils-unwrapped = { name = "bootstrap-stage0-binutils"; outPath = bootstrapTools; };
268 name = "bootstrap-stage0-cctools";
269 outPath = bootstrapTools;
273 binutils = lib.makeOverridable (import ../../build-support/bintools-wrapper) {
274 shell = "${bootstrapTools}/bin/bash";
276 inherit (self) stdenvNoCC;
280 inherit (self) buildPackages coreutils gnugrep;
281 libc = selfDarwin.Libsystem;
282 bintools = selfDarwin.binutils-unwrapped;
283 inherit (selfDarwin) postLinkSignHook signingUtils;
285 } // lib.optionalAttrs (! useAppleSDKLibs) {
286 CF = stdenv.mkDerivation {
287 name = "bootstrap-stage0-CF";
289 mkdir -p $out/Library/Frameworks
290 ln -s ${bootstrapTools}/Library/Frameworks/CoreFoundation.framework $out/Library/Frameworks
294 Libsystem = stdenv.mkDerivation {
295 name = "bootstrap-stage0-Libsystem";
299 cp -r ${selfDarwin.darwin-stubs}/usr/lib $out/lib
301 substituteInPlace $out/lib/libSystem.B.tbd --replace /usr/lib/system $out/lib/system
303 ln -s libSystem.B.tbd $out/lib/libSystem.tbd
305 for name in c dbm dl info m mx poll proc pthread rpcsvc util gcc_s.10.4 gcc_s.10.5; do
306 ln -s libSystem.tbd $out/lib/lib$name.tbd
309 ln -s ${bootstrapTools}/lib/*.o $out/lib
311 ln -s ${bootstrapTools}/lib/libresolv.9.dylib $out/lib
312 ln -s libresolv.9.dylib $out/lib/libresolv.dylib
314 ln -s ${bootstrapTools}/include-Libsystem $out/include
319 "${finalLlvmPackages}" = {
320 clang-unwrapped = stdenv.mkDerivation {
321 name = "bootstrap-stage0-clang";
322 version = bootstrapLlvmVersion;
325 ln -s ${bootstrapTools}/bin $out/bin
326 ln -s ${bootstrapTools}/lib/clang $out/lib/clang
327 ln -s ${bootstrapTools}/include $out/include
331 libcxx = stdenv.mkDerivation {
332 name = "bootstrap-stage0-libcxx";
335 mkdir -p $out/lib $out/include
336 ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib
337 ln -s ${bootstrapTools}/include/c++ $out/include/c++
344 libcxxabi = stdenv.mkDerivation {
345 name = "bootstrap-stage0-libcxxabi";
348 ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
352 compiler-rt = stdenv.mkDerivation {
353 name = "bootstrap-stage0-compiler-rt";
356 ln -s ${bootstrapTools}/lib/libclang_rt* $out/lib
357 ln -s ${bootstrapTools}/lib/darwin $out/lib/darwin
363 extraNativeBuildInputs = [ ];
364 extraBuildInputs = [ ];
370 persistent = self: super: with prevStage; {
371 cmake = super.cmakeMinimal;
373 curl = super.curlMinimal;
377 python3 = super.python3Minimal;
379 ninja = super.ninja.override { buildDocs = false; };
381 "${finalLlvmPackages}" = super."${finalLlvmPackages}" // (
383 tools = super."${finalLlvmPackages}".tools.extend (_: _: {
384 inherit (pkgs."${finalLlvmPackages}") clang-unwrapped;
386 libraries = super."${finalLlvmPackages}".libraries.extend (_: _: {
387 inherit (pkgs."${finalLlvmPackages}") compiler-rt libcxx libcxxabi;
390 { inherit tools libraries; } // tools // libraries
393 darwin = super.darwin.overrideScope (selfDarwin: _: {
394 inherit (darwin) rewrite-tbd binutils-unwrapped;
396 signingUtils = darwin.signingUtils.override {
397 inherit (selfDarwin) sigtool;
400 binutils = darwin.binutils.override {
401 coreutils = self.coreutils;
402 libc = selfDarwin.Libsystem;
403 inherit (selfDarwin) postLinkSignHook signingUtils;
408 with prevStage; stageFun 1 prevStage {
409 extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
410 extraNativeBuildInputs = [ ];
411 extraBuildInputs = [ pkgs.darwin.CF ];
412 libcxx = pkgs."${finalLlvmPackages}".libcxx;
415 [ bootstrapTools ] ++
416 (with pkgs; [ coreutils gnugrep ]) ++
417 (with pkgs."${finalLlvmPackages}"; [ libcxx libcxxabi compiler-rt clang-unwrapped ]) ++
418 (with pkgs.darwin; [ Libsystem CF ] ++ lib.optional useAppleSDKLibs objc4);
420 overrides = persistent;
425 persistent = self: super: with prevStage; {
427 zlib patchutils m4 scons flex perl bison unifdef unzip openssl python3
428 libxml2 gettext sharutils gmp libarchive ncurses pkg-config libedit groff
429 openssh sqlite sed serf openldap db cyrus-sasl expat apr-util subversion xz
430 findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils
431 libssh2 nghttp2 libkrb5 ninja brotli libiconv;
433 "${finalLlvmPackages}" = super."${finalLlvmPackages}" // (
435 tools = super."${finalLlvmPackages}".tools.extend (_: _: {
436 inherit (pkgs."${finalLlvmPackages}") clang-unwrapped;
438 libraries = super."${finalLlvmPackages}".libraries.extend (_: libSuper: {
439 inherit (pkgs."${finalLlvmPackages}") compiler-rt;
440 libcxx = libSuper.libcxx.override {
441 stdenv = overrideCC self.stdenv self.ccNoLibcxx;
443 libcxxabi = libSuper.libcxxabi.override ({
444 stdenv = overrideCC self.stdenv self.ccNoLibcxx;
445 } // lib.optionalAttrs (builtins.any (v: finalLlvmVersion == v) [ 7 11 12 13 ]) {
446 # TODO: the bootstrapping of llvm packages isn't consistent.
447 # `standalone` may be redundant if darwin behaves like useLLVM (or
448 # has useLLVM = true).
453 { inherit tools libraries; } // tools // libraries
456 darwin = super.darwin.overrideScope (_: _: {
458 binutils dyld Libsystem xnu configd ICU libdispatch libclosure
459 launchd CF objc4 darwin-stubs sigtool postLinkSignHook signingUtils;
463 with prevStage; stageFun 2 prevStage {
465 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
468 extraNativeBuildInputs = [ pkgs.xz ];
469 extraBuildInputs = [ pkgs.darwin.CF ];
470 libcxx = pkgs."${finalLlvmPackages}".libcxx;
473 [ bootstrapTools ] ++
490 ] ++ lib.optional haveKRB5 libkrb5) ++
491 (with pkgs."${finalLlvmPackages}"; [
497 (with pkgs.darwin; [ dyld Libsystem CF ICU locale ] ++ lib.optional useAppleSDKLibs objc4);
499 overrides = persistent;
504 persistent = self: super: with prevStage; {
506 patchutils m4 scons flex perl bison unifdef unzip openssl python3
507 gettext sharutils libarchive pkg-config groff bash subversion
508 openssh sqlite sed serf openldap db cyrus-sasl expat apr-util
509 findfreetype libssh curl cmake autoconf automake libtool cpio
510 libssh2 nghttp2 libkrb5 ninja;
512 # Avoid pulling in a full python and its extra dependencies for the llvm/clang builds.
513 libxml2 = super.libxml2.override { pythonSupport = false; };
515 "${finalLlvmPackages}" = super."${finalLlvmPackages}" // (
517 libraries = super."${finalLlvmPackages}".libraries.extend (_: _: {
518 inherit (pkgs."${finalLlvmPackages}") libcxx libcxxabi;
521 { inherit libraries; } // libraries
524 darwin = super.darwin.overrideScope (_: _: {
526 dyld Libsystem xnu configd libdispatch libclosure launchd libiconv
527 locale darwin-stubs sigtool;
531 with prevStage; stageFun 3 prevStage {
532 shell = "${pkgs.bash}/bin/bash";
534 # We have a valid shell here (this one has no bootstrap-tools runtime deps) so stageFun
535 # enables patchShebangs above. Unfortunately, patchShebangs ignores our $SHELL setting
536 # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and
537 # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first.
538 extraNativeBuildInputs = with pkgs; [ xz ];
539 extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ];
540 libcxx = pkgs."${finalLlvmPackages}".libcxx;
543 export PATH=${pkgs.bash}/bin:$PATH
544 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
548 [ bootstrapTools ] ++
566 ] ++ lib.optional haveKRB5 libkrb5) ++
567 (with pkgs."${finalLlvmPackages}"; [
575 (with pkgs.darwin; [ dyld ICU Libsystem locale ] ++ lib.optional useAppleSDKLibs objc4);
577 overrides = persistent;
582 persistent = self: super: with prevStage; {
584 gnumake gzip gnused bzip2 gawk ed xz patch bash python3
585 ncurses libffi zlib gmp pcre gnugrep cmake
586 coreutils findutils diffutils patchutils ninja libxml2;
588 # Hack to make sure we don't link ncurses in bootstrap tools. The proper
589 # solution is to avoid passing -L/nix-store/...-bootstrap-tools/lib,
590 # quite a sledgehammer just to get the C runtime.
591 gettext = super.gettext.overrideAttrs (drv: {
592 configureFlags = drv.configureFlags ++ [
597 "${finalLlvmPackages}" = super."${finalLlvmPackages}" // (
599 tools = super."${finalLlvmPackages}".tools.extend (llvmSelf: _: {
600 clang-unwrapped-all-outputs = pkgs."${finalLlvmPackages}".clang-unwrapped-all-outputs.override { llvm = llvmSelf.llvm; };
601 libllvm = pkgs."${finalLlvmPackages}".libllvm.override { inherit libxml2; };
603 libraries = super."${finalLlvmPackages}".libraries.extend (llvmSelf: _: {
604 inherit (pkgs."${finalLlvmPackages}") libcxx libcxxabi compiler-rt;
607 { inherit tools libraries; } // tools // libraries
610 darwin = super.darwin.overrideScope (_: superDarwin: {
611 inherit (darwin) dyld Libsystem libiconv locale darwin-stubs;
613 # See useAppleSDKLibs in darwin-packages.nix
614 CF = if useAppleSDKLibs then super.darwin.CF else
615 superDarwin.CF.override {
617 python3 = prevStage.python3;
622 with prevStage; stageFun 4 prevStage {
623 shell = "${pkgs.bash}/bin/bash";
624 extraNativeBuildInputs = with pkgs; [ xz ];
625 extraBuildInputs = [ pkgs.darwin.CF pkgs.bash ];
626 libcxx = pkgs."${finalLlvmPackages}".libcxx;
629 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
631 overrides = persistent;
634 stdenvDarwin = prevStage:
636 doSign = localSystem.isAarch64;
638 persistent = self: super: with prevStage; {
640 gnumake gzip gnused bzip2 gawk ed xz patch bash
641 ncurses libffi zlib gmp pcre gnugrep
642 coreutils findutils diffutils patchutils pbzx;
644 darwin = super.darwin.overrideScope (_: _: {
645 inherit (darwin) dyld ICU Libsystem Csu libiconv rewrite-tbd;
646 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
647 inherit (darwin) binutils binutils-unwrapped cctools;
649 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
652 # Need to get rid of these when cross-compiling.
653 "${finalLlvmPackages}" = super."${finalLlvmPackages}" // (
655 tools = super."${finalLlvmPackages}".tools.extend (_: super: {
656 inherit (pkgs."${finalLlvmPackages}") llvm clang-unwrapped;
658 libraries = super."${finalLlvmPackages}".libraries.extend (_: _: {
659 inherit (pkgs."${finalLlvmPackages}") compiler-rt libcxx libcxxabi;
662 { inherit tools libraries; } // tools // libraries
665 inherit binutils binutils-unwrapped;
668 import ../generic rec {
669 name = "stdenv-darwin";
672 inherit (pkgs.stdenv) fetchurlBoot;
674 buildPlatform = localSystem;
675 hostPlatform = localSystem;
676 targetPlatform = localSystem;
678 preHook = commonPreHook + ''
679 export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks
680 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
683 __stdenvImpureHostDeps = commonImpureHostDeps;
684 __extraImpureHostDeps = commonImpureHostDeps;
686 initialPath = import ../generic/common-path.nix { inherit pkgs; };
687 shell = "${pkgs.bash}/bin/bash";
689 cc = pkgs."${finalLlvmPackages}".libcxxClang;
691 extraNativeBuildInputs = lib.optionals localSystem.isAarch64 [
692 pkgs.updateAutotoolsGnuConfigScriptsHook
695 extraBuildInputs = [ pkgs.darwin.CF ];
698 libc = pkgs.darwin.Libsystem;
699 shellPackage = pkgs.bash;
700 inherit bootstrapTools;
701 } // lib.optionalAttrs useAppleSDKLibs {
702 # This objc4 will be propagated to all builds using the final stdenv,
703 # and we shouldn't mix different builds, because they would be
704 # conflicting LLVM modules. Export it here so we can grab it later.
705 inherit (pkgs.darwin) objc4;
708 allowedRequisites = (with pkgs; [
736 darwin.binutils.bintools
745 cc.expand-response-params
748 ] ++ lib.optional haveKRB5 libkrb5
749 ++ lib.optionals localSystem.isAarch64 [
750 pkgs.updateAutotoolsGnuConfigScriptsHook
753 ++ (with pkgs."${finalLlvmPackages}"; [
766 ++ (with pkgs.darwin; [
775 ] ++ lib.optional useAppleSDKLibs objc4
776 ++ lib.optionals doSign [ postLinkSignHook sigtool signingUtils ]);
778 overrides = lib.composeExtensions persistent (self: super: {
779 darwin = super.darwin.overrideScope (_: superDarwin: {
780 inherit (prevStage.darwin) CF darwin-stubs;
781 xnu = superDarwin.xnu.override { inherit (prevStage) python3; };
783 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) {
785 llvmPackages = super.llvmPackages // { clang = cc; };
797 inherit config overlays;
798 stdenv = stdenvDarwin prevStage;