Skip to content

Commit 5643714

Browse files
committed
stdenvBootstrapTools: inherit {cross,local}System
It's expected that attributes in the top-level package set will all use that package set, but this wasn't the case for the bootstrap tools. This led some very confusing behaviour: - pkgsMusl.stdenvBootstrapTools would build glibc bootstrap tools - stdenvBootstrapTools was _always_ cross compiled, even if Nixpkgs wasn't, because it always set crossSystem. This also didn't match the behaviour of using make-bootstrap-tools.nix as an entrypoint, where crossSystem would default to null. For the Linux stdenv, I've made the ideal fix, which is to make pkgs an argument rather than taking the arguments for pkgs, and then re-importing it. This means it'll always use exactly the same package set that's calling it, and should also mean faster eval due to not importing Nixpkgs twice. The Darwin stdenv is more complicated, and I'm not able to easily test it, so I wasn't confident in making the same fix there. Instead, I've just made sure crossSystem and localSystem are set to the correct values so they're not always cross compiled and match the parent package set's. It would still be preferable if somebody could make Darwin's make-bootstrap-tools.nix take pkgs as an argument, rather than all the arguments for pkgs.
1 parent c5d82eb commit 5643714

3 files changed

Lines changed: 15 additions & 14 deletions

File tree

pkgs/stdenv/darwin/make-bootstrap-tools.nix

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{ pkgspath ? ../../.., test-pkgspath ? pkgspath
2-
, system ? builtins.currentSystem, crossSystem ? null, bootstrapFiles ? null
2+
, localSystem ? { system = builtins.currentSystem; }
3+
, crossSystem ? null
4+
, bootstrapFiles ? null
35
}:
46

57
let cross = if crossSystem != null
@@ -11,7 +13,7 @@ let cross = if crossSystem != null
1113
in (import "${pkgspath}/pkgs/stdenv/darwin" args').stagesDarwin;
1214
}
1315
else {};
14-
in with import pkgspath ({ inherit system; } // cross // custom-bootstrap);
16+
in with import pkgspath ({ inherit localSystem; } // cross // custom-bootstrap);
1517

1618
let
1719
llvmPackages = llvmPackages_11;
@@ -364,7 +366,7 @@ in rec {
364366
test-pkgs = import test-pkgspath {
365367
# if the bootstrap tools are for another platform, we should be testing
366368
# that platform.
367-
system = if crossSystem != null then crossSystem else system;
369+
localSystem = if crossSystem != null then crossSystem else localSystem;
368370

369371
stdenvStages = args: let
370372
args' = args // { inherit bootstrapLlvmVersion bootstrapFiles; };

pkgs/stdenv/linux/make-bootstrap-tools.nix

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
{ localSystem ? { system = builtins.currentSystem; }
2-
, crossSystem ? null
3-
}:
1+
{ pkgs ? import ../../.. {} }:
42

53
let
6-
pkgs = import ../../.. { inherit localSystem crossSystem; };
74
libc = pkgs.stdenv.cc.libc;
85
in with pkgs; rec {
96

pkgs/top-level/all-packages.nix

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,13 +1918,15 @@ with pkgs;
19181918

19191919
brewtarget = libsForQt514.callPackage ../applications/misc/brewtarget { } ;
19201920

1921-
stdenvBootstrapTools =
1922-
let args = { crossSystem = stdenv.hostPlatform.system; }; in
1923-
if stdenv.hostPlatform.isDarwin
1924-
then callPackage ../stdenv/darwin/make-bootstrap-tools.nix args
1925-
else if stdenv.hostPlatform.isLinux
1926-
then callPackage ../stdenv/linux/make-bootstrap-tools.nix args
1927-
else throw "stdenvBootstrapTools: unknown hostPlatform ${stdenv.hostPlatform.config}";
1921+
stdenvBootstrapTools = if stdenv.hostPlatform.isDarwin then
1922+
callPackage ../stdenv/darwin/make-bootstrap-tools.nix {
1923+
localSystem = stdenv.buildPlatform;
1924+
crossSystem =
1925+
if stdenv.buildPlatform == stdenv.hostPlatform then null else stdenv.hostPlatform;
1926+
}
1927+
else if stdenv.hostPlatform.isLinux then
1928+
callPackage ../stdenv/linux/make-bootstrap-tools.nix {}
1929+
else throw "stdenvBootstrapTools: unknown hostPlatform ${stdenv.hostPlatform.config}";
19281930

19291931
boxes = callPackage ../tools/text/boxes { };
19301932

0 commit comments

Comments
 (0)