git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #59897 from matthewbauer/mb-cross-fixes2

Miscellaneous cross compilation fixes

commitc351eb2842367845790fda0631ac9917ce6c832b authorMatthew Bauer <mjbauer95@gmail.com> dateSat 20 Apr 2019, 16:52 (8 years ago) parentbfd9eae4224b03
9 files changed+77−29
lib/systems/default.nix+10−4 lib/systems/parse.nix+33−13 pkgs/development/interpreters/spidermonkey/52.nix+6−2 pkgs/development/libraries/aws-c-common/default.nix+3−1 pkgs/os-specific/linux/kernel-headers/default.nix+1−1 pkgs/os-specific/linux/systemd/default.nix+4−4 pkgs/stdenv/default.nix+6 pkgs/stdenv/linux/default.nix+11−3 pkgs/top-level/impure.nix+3−1
lib/systems/default.nix+10−4
@@ -72,16 +72,22 @@ rec {
7272 release = null;
7373 };
7474
75+ kernelArch =
76+ if final.isAarch32 then "arm"
77+ else if final.isAarch64 then "arm64"
78+ else if final.isx86_32 then "x86"
79+ else if final.isx86_64 then "ia64"
80+ else final.parsed.cpu.name;
81+
7582 qemuArch =
7683 if final.isArm then "arm"
7784 else if final.isx86_64 then "x86_64"
7885 else if final.isx86 then "i386"
7986 else {
8087 "powerpc" = "ppc";
88+ "powerpcle" = "ppc";
8189 "powerpc64" = "ppc64";
82− "powerpc64le" = "ppc64";
83− "mips64" = "mips";
84− "mipsel64" = "mipsel";
90+ "powerpc64le" = "ppc64le";
8591 }.${final.parsed.cpu.name} or final.parsed.cpu.name;
8692
8793 emulator = pkgs: let
@@ -103,7 +109,7 @@ rec {
103109 in
104110 if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name &&
105111 pkgs.stdenv.hostPlatform.isCompatible final
106− then "${pkgs.runtimeShell} -c"
112+ then "${pkgs.runtimeShell} -c '\"$@\"' --"
107113 else if final.isWindows
108114 then "${wine}/bin/${wine-name}"
109115 else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux
lib/systems/parse.nix+33−13
@@ -127,22 +127,42 @@ rec {
127127 (b == i386 && isCompatible a i486)
128128 (b == i486 && isCompatible a i586)
129129 (b == i586 && isCompatible a i686)
130− # NOTE: Not true in some cases. Like in WSL mode.
130+
131+ # XXX: Not true in some cases. Like in WSL mode.
131132 (b == i686 && isCompatible a x86_64)
132133
133− # ARM
134+ # ARMv4
134135 (b == arm && isCompatible a armv5tel)
135− (b == armv5tel && isCompatible a armv6m)
136− (b == armv6m && isCompatible a armv6l)
137− (b == armv6l && isCompatible a armv7a)
138− (b == armv7a && isCompatible a armv7r)
139− (b == armv7r && isCompatible a armv7m)
140− (b == armv7m && isCompatible a armv7l)
141− (b == armv7l && isCompatible a armv8a)
142− (b == armv8a && isCompatible a armv8r)
143− (b == armv8r && isCompatible a armv8m)
144− # NOTE: not always true! Some arm64 cpus don’t support arm32 mode.
145− (b == armv8m && isCompatible a aarch64)
136+
137+ # ARMv5
138+ (b == armv5tel && isCompatible a armv6l)
139+
140+ # ARMv6
141+ (b == armv6l && isCompatible a armv6m)
142+ (b == armv6m && isCompatible a armv7l)
143+
144+ # ARMv7
145+ (b == armv7l && isCompatible a armv7a)
146+ (b == armv7l && isCompatible a armv7r)
147+ (b == armv7l && isCompatible a armv7m)
148+ (b == armv7a && isCompatible a armv8a)
149+ (b == armv7r && isCompatible a armv8a)
150+ (b == armv7m && isCompatible a armv8a)
151+ (b == armv7a && isCompatible a armv8r)
152+ (b == armv7r && isCompatible a armv8r)
153+ (b == armv7m && isCompatible a armv8r)
154+ (b == armv7a && isCompatible a armv8m)
155+ (b == armv7r && isCompatible a armv8m)
156+ (b == armv7m && isCompatible a armv8m)
157+
158+ # ARMv8
159+ (b == armv8r && isCompatible a armv8a)
160+ (b == armv8m && isCompatible a armv8a)
161+
162+ # XXX: not always true! Some arm64 cpus don’t support arm32 mode.
163+ (b == aarch64 && a == armv8a)
164+ (b == armv8a && isCompatible a aarch64)
165+
146166 (b == aarch64 && a == aarch64_be)
147167 (b == aarch64_be && isCompatible a aarch64)
148168
pkgs/development/interpreters/spidermonkey/52.nix+6−2
@@ -31,7 +31,7 @@ in stdenv.mkDerivation rec {
3131 })
3232 ];
3333
34− configurePlatforms = [ "host" "target" ];
34+ configurePlatforms = [ ];
3535
3636 preConfigure = ''
3737 export CXXFLAGS="-fpermissive"
@@ -51,7 +51,11 @@ in stdenv.mkDerivation rec {
5151 "--with-intl-api"
5252 "--enable-readline"
5353 "--enable-shared-js"
54− ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc";
54+ ] ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-jemalloc"
55+ ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
56+ "--host=${stdenv.buildPlatform.config}"
57+ "--target=${stdenv.hostPlatform.config}"
58+ ];
5559
5660 makeFlags = [
5761 "HOST_CC=${buildPackages.stdenv.cc}/bin/cc"
pkgs/development/libraries/aws-c-common/default.nix+3−1
@@ -1,4 +1,4 @@
1−{ lib, stdenv, fetchFromGitHub, cmake }:
1+{ lib, stdenv, fetchFromGitHub, cmake, libexecinfo }:
22
33stdenv.mkDerivation rec {
44 pname = "aws-c-common";
@@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
1313
1414 nativeBuildInputs = [ cmake ];
1515
16+ buildInputs = lib.optional stdenv.hostPlatform.isMusl libexecinfo;
17+
1618 NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [
1719 "-Wno-nullability-extension"
1820 "-Wno-typedef-redefinition"
pkgs/os-specific/linux/kernel-headers/default.nix+1−1
@@ -12,7 +12,7 @@ let
1212 inherit sha256;
1313 };
1414
15− ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or (throw "missing kernelArch");
15+ ARCH = stdenvNoCC.hostPlatform.platform.kernelArch or stdenvNoCC.hostPlatform.kernelArch;
1616
1717 # It may look odd that we use `stdenvNoCC`, and yet explicit depend on a cc.
1818 # We do this so we have a build->build, not build->host, C compiler.
pkgs/os-specific/linux/systemd/default.nix+4−4
@@ -129,12 +129,12 @@ in stdenv.mkDerivation rec {
129129 test -e $i
130130 substituteInPlace $i \
131131 --replace /usr/bin/getent ${getent}/bin/getent \
132− --replace /sbin/swapon ${utillinux.bin}/sbin/swapon \
133− --replace /sbin/swapoff ${utillinux.bin}/sbin/swapoff \
134− --replace /sbin/fsck ${utillinux.bin}/sbin/fsck \
132+ --replace /sbin/swapon ${lib.getBin utillinux}/sbin/swapon \
133+ --replace /sbin/swapoff ${lib.getBin utillinux}/sbin/swapoff \
134+ --replace /sbin/fsck ${lib.getBin utillinux}/sbin/fsck \
135135 --replace /bin/echo ${coreutils}/bin/echo \
136136 --replace /bin/cat ${coreutils}/bin/cat \
137− --replace /sbin/sulogin ${utillinux.bin}/sbin/sulogin \
137+ --replace /sbin/sulogin ${lib.getBin utillinux}/sbin/sulogin \
138138 --replace /usr/lib/systemd/systemd-fsck $out/lib/systemd/systemd-fsck \
139139 --replace /bin/plymouth /run/current-system/sw/bin/plymouth # To avoid dependency
140140 done
pkgs/stdenv/default.nix+6
@@ -43,8 +43,14 @@ in
4343 "x86_64-linux" = stagesLinux;
4444 "armv5tel-linux" = stagesLinux;
4545 "armv6l-linux" = stagesLinux;
46+ "armv6m-linux" = stagesLinux;
4647 "armv7a-linux" = stagesLinux;
4748 "armv7l-linux" = stagesLinux;
49+ "armv7r-linux" = stagesLinux;
50+ "armv7m-linux" = stagesLinux;
51+ "armv8a-linux" = stagesLinux;
52+ "armv8r-linux" = stagesLinux;
53+ "armv8m-linux" = stagesLinux;
4854 "aarch64-linux" = stagesLinux;
4955 "mipsel-linux" = stagesLinux;
5056 "powerpc-linux" = /* stagesLinux */ stagesNative;
pkgs/stdenv/linux/default.nix+11−3
@@ -13,7 +13,6 @@
1313 "x86_64-linux" = import ./bootstrap-files/x86_64.nix;
1414 "armv5tel-linux" = import ./bootstrap-files/armv5tel.nix;
1515 "armv6l-linux" = import ./bootstrap-files/armv6l.nix;
16− "armv7a-linux" = import ./bootstrap-files/armv7l.nix;
1716 "armv7l-linux" = import ./bootstrap-files/armv7l.nix;
1817 "aarch64-linux" = import ./bootstrap-files/aarch64.nix;
1918 "mipsel-linux" = import ./bootstrap-files/loongson2f.nix;
@@ -26,10 +25,19 @@
2625 "powerpc64le-linux" = import ./bootstrap-files/ppc64le-musl.nix;
2726 };
2827 };
28+
29+ # Try to find an architecture compatible with our current system. We
30+ # just try every bootstrap we’ve got and test to see if it is
31+ # compatible with or current architecture.
32+ getCompatibleTools = lib.foldl (v: system:
33+ if v != null then v
34+ else if localSystem.isCompatible (lib.systems.elaborate { inherit system; }) then archLookupTable.${system}
35+ else null) null (lib.attrNames archLookupTable);
36+
2937 archLookupTable = table.${localSystem.libc}
3038 or (abort "unsupported libc for the pure Linux stdenv");
31− files = archLookupTable.${localSystem.system}
32− or (abort "unsupported platform for the pure Linux stdenv");
39+ files = archLookupTable.${localSystem.system} or (if getCompatibleTools != null then getCompatibleTools
40+ else (abort "unsupported platform for the pure Linux stdenv"));
3341 in files
3442}:
3543
pkgs/top-level/impure.nix+3−1
@@ -72,6 +72,8 @@ in
7272 else overlays homeOverlaysDir
7373 else []
7474
75+, crossOverlays ? []
76+
7577, ...
7678} @ args:
7779
@@ -80,7 +82,7 @@ in
8082assert args ? localSystem -> !(args ? system || args ? platform);
8183
8284import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
83− inherit config overlays crossSystem;
85+ inherit config overlays crossSystem crossOverlays;
8486 # Fallback: Assume we are building packages on the current (build, in GNU
8587 # Autotools parlance) system.
8688 localSystem = (if args ? localSystem then {}