1 /* This file defines some basic smoke tests for cross compilation.
2 Individual jobs can be tested by running:
4 $ nix-build pkgs/top-level/release-cross.nix -A <jobname>.<package> --arg supportedSystems '[builtins.currentSystem]'
8 $ nix-build pkgs/top-level/release-cross.nix -A crossMingw32.nixUnstable --arg supportedSystems '[builtins.currentSystem]'
10 To build all of the bootstrapFiles bundles on every enabled platform, use:
12 $ nix-build --expr 'with import ./pkgs/top-level/release-cross.nix {supportedSystems = [builtins.currentSystem];}; builtins.mapAttrs (k: v: v.build) bootstrapTools'
15 { # The platforms *from* which we cross compile.
16 supportedSystems ? [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" ]
17 , # Strip most of attributes when evaluating to spare memory usage
19 , # Attributes passed to nixpkgs. Don't build packages marked as unfree.
20 nixpkgsArgs ? { config = { allowUnfree = false; inHydra = true; }; }
23 with import ./release-lib.nix { inherit supportedSystems scrubJobs nixpkgsArgs; };
26 nativePlatforms = all;
29 buildPackages.binutils = nativePlatforms;
30 buildPackages.gcc = nativePlatforms;
31 libcCross = nativePlatforms;
35 buildPackages.binutils = nativePlatforms;
36 gmp = nativePlatforms;
37 libcCross = nativePlatforms;
38 nix = nativePlatforms;
39 nixUnstable = nativePlatforms;
40 mesa = nativePlatforms;
41 rustc = nativePlatforms;
42 cargo = nativePlatforms;
45 gnuCommon = lib.recursiveUpdate common {
46 buildPackages.gcc = nativePlatforms;
47 coreutils = nativePlatforms;
48 haskell.packages.ghcHEAD.hello = nativePlatforms;
49 haskellPackages.hello = nativePlatforms;
52 linuxCommon = lib.recursiveUpdate gnuCommon {
53 buildPackages.gdb = nativePlatforms;
55 bison = nativePlatforms;
56 busybox = nativePlatforms;
57 dropbear = nativePlatforms;
59 ncurses = nativePlatforms;
60 patch = nativePlatforms;
63 windowsCommon = lib.recursiveUpdate gnuCommon {
64 boehmgc = nativePlatforms;
65 guile_1_8 = nativePlatforms;
66 libffi = nativePlatforms;
67 libtool = nativePlatforms;
68 libunistring = nativePlatforms;
69 windows.wxMSW = nativePlatforms;
70 windows.mingw_w64_pthreads = nativePlatforms;
74 gmp = nativePlatforms;
75 boehmgc = nativePlatforms;
76 hello = nativePlatforms;
77 zlib = nativePlatforms;
81 buildPackages.binutils = darwin;
84 rpiCommon = linuxCommon // {
85 vim = nativePlatforms;
86 unzip = nativePlatforms;
87 ddrescue = nativePlatforms;
88 lynx = nativePlatforms;
89 patchelf = nativePlatforms;
90 buildPackages.binutils = nativePlatforms;
91 mpg123 = nativePlatforms;
94 # Enabled-but-unsupported platforms for which nix is known to build.
95 # We provide Hydra-built `nixStatic` for these platforms. This
96 # allows users to bootstrap their own system without either (a)
97 # trusting binaries from a non-Hydra source or (b) having to fight
98 # with their host distribution's versions of nix's numerous
101 nixStatic = linux; # no need for buildPlatform=*-darwin
107 # These derivations from a cross package set's `buildPackages` should be
108 # identical to their vanilla equivalents --- none of these package should
109 # observe the target platform which is the only difference between those
111 ensureUnaffected = let
112 # Absurd values are fine here, as we are not building anything. In fact,
113 # there probably a good idea to try to be "more parametric" --- i.e. avoid
114 # any special casing.
116 config = "mips64el-apple-windows-gnu";
120 # Converting to a string (drv path) before checking equality is probably a
121 # good idea lest there be some irrelevant pass-through debug attrs that
122 # cause false negatives.
123 testEqualOne = path: system: let
124 f = path: crossSystem: system: builtins.toString (lib.getAttrFromPath path (pkgsForCross crossSystem system));
128 f (["buildPackages"] ++ path) crossSystem system
131 testEqual = path: systems: forMatchingSystems systems (testEqualOne path);
133 mapTestEqual = lib.mapAttrsRecursive testEqual;
136 boehmgc = nativePlatforms;
137 libffi = nativePlatforms;
138 libiconv = nativePlatforms;
139 libtool = nativePlatforms;
140 zlib = nativePlatforms;
141 readline = nativePlatforms;
142 libxml2 = nativePlatforms;
143 guile = nativePlatforms;
146 crossIphone64 = mapTestOnCross lib.systems.examples.iphone64 darwinCommon;
148 crossIphone32 = mapTestOnCross lib.systems.examples.iphone32 darwinCommon;
150 /* Test some cross builds to the Sheevaplug */
151 crossSheevaplugLinux = mapTestOnCross lib.systems.examples.sheevaplug (linuxCommon // {
152 ubootSheevaplug = nativePlatforms;
155 /* Test some cross builds on 32 bit mingw-w64 */
156 crossMingw32 = mapTestOnCross lib.systems.examples.mingw32 windowsCommon;
158 /* Test some cross builds on 64 bit mingw-w64 */
159 crossMingwW64 = mapTestOnCross lib.systems.examples.mingwW64 windowsCommon;
161 /* Linux on mipsel */
162 fuloongminipc = mapTestOnCross lib.systems.examples.fuloongminipc linuxCommon;
163 ben-nanonote = mapTestOnCross lib.systems.examples.ben-nanonote linuxCommon;
166 ghcjs = mapTestOnCross lib.systems.examples.ghcjs {
167 haskell.packages.ghcjs.hello = nativePlatforms;
168 haskell.packages.native-bignum.ghcHEAD.hello = nativePlatforms;
169 haskellPackages.hello = nativePlatforms;
172 /* Linux on Raspberrypi */
173 rpi = mapTestOnCross lib.systems.examples.raspberryPi rpiCommon;
174 rpi-musl = mapTestOnCross lib.systems.examples.muslpi rpiCommon;
176 /* Linux on the Remarkable */
177 remarkable1 = mapTestOnCross lib.systems.examples.remarkable1 linuxCommon;
178 remarkable2 = mapTestOnCross lib.systems.examples.remarkable2 linuxCommon;
180 /* Linux on armv7l-hf */
181 armv7l-hf = mapTestOnCross lib.systems.examples.armv7l-hf-multiplatform linuxCommon;
183 pogoplug4 = mapTestOnCross lib.systems.examples.pogoplug4 linuxCommon;
185 /* Linux on aarch64 */
186 aarch64 = mapTestOnCross lib.systems.examples.aarch64-multiplatform linuxCommon;
187 aarch64-musl = mapTestOnCross lib.systems.examples.aarch64-multiplatform-musl linuxCommon;
190 riscv64 = mapTestOnCross lib.systems.examples.riscv64 linuxCommon;
191 riscv32 = mapTestOnCross lib.systems.examples.riscv32 linuxCommon;
193 /* Linux on LoongArch */
194 loongarch64-linux = mapTestOnCross lib.systems.examples.loongarch64-linux linuxCommon;
196 m68k = mapTestOnCross lib.systems.examples.m68k linuxCommon;
197 s390x = mapTestOnCross lib.systems.examples.s390x linuxCommon;
199 /* (Cross-compiled) Linux on x86 */
200 x86_64-musl = mapTestOnCross lib.systems.examples.musl64 linuxCommon;
201 x86_64-gnu = mapTestOnCross lib.systems.examples.gnu64 linuxCommon;
202 i686-musl = mapTestOnCross lib.systems.examples.musl32 linuxCommon;
203 i686-gnu = mapTestOnCross lib.systems.examples.gnu32 linuxCommon;
205 ppc64le = mapTestOnCross lib.systems.examples.powernv linuxCommon;
206 ppc64le-musl = mapTestOnCross lib.systems.examples.musl-power linuxCommon;
208 android64 = mapTestOnCross lib.systems.examples.aarch64-android-prebuilt linuxCommon;
209 android32 = mapTestOnCross lib.systems.examples.armv7a-android-prebuilt linuxCommon;
211 wasi32 = mapTestOnCross lib.systems.examples.wasi32 wasiCommon;
213 msp430 = mapTestOnCross lib.systems.examples.msp430 embedded;
214 mmix = mapTestOnCross lib.systems.examples.mmix embedded;
215 vc4 = mapTestOnCross lib.systems.examples.vc4 embedded;
216 or1k = mapTestOnCross lib.systems.examples.or1k embedded;
217 avr = mapTestOnCross lib.systems.examples.avr embedded;
218 arm-embedded = mapTestOnCross lib.systems.examples.arm-embedded embedded;
219 armhf-embedded = mapTestOnCross lib.systems.examples.armhf-embedded embedded;
220 aarch64-embedded = mapTestOnCross lib.systems.examples.aarch64-embedded embedded;
221 aarch64be-embedded = mapTestOnCross lib.systems.examples.aarch64be-embedded embedded;
222 powerpc-embedded = mapTestOnCross lib.systems.examples.ppc-embedded embedded;
223 powerpcle-embedded = mapTestOnCross lib.systems.examples.ppcle-embedded embedded;
224 i686-embedded = mapTestOnCross lib.systems.examples.i686-embedded embedded;
225 x86_64-embedded = mapTestOnCross lib.systems.examples.x86_64-embedded embedded;
226 riscv64-embedded = mapTestOnCross lib.systems.examples.riscv64-embedded embedded;
227 riscv32-embedded = mapTestOnCross lib.systems.examples.riscv32-embedded embedded;
228 rx-embedded = mapTestOnCross lib.systems.examples.rx-embedded embedded;
230 x86_64-freebsd = mapTestOnCross lib.systems.examples.x86_64-freebsd common;
231 x86_64-netbsd = mapTestOnCross lib.systems.examples.x86_64-netbsd common;
233 # we test `embedded` instead of `linuxCommon` because very few packages
234 # successfully cross-compile to Redox so far
235 x86_64-redox = mapTestOnCross lib.systems.examples.x86_64-unknown-redox embedded;
237 /* Cross-built bootstrap tools for every supported platform */
239 tools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
240 maintainers = [ lib.maintainers.dezgeg ];
241 mkBootstrapToolsJob = drv:
242 assert lib.elem drv.system supportedSystems;
243 hydraJob' (lib.addMetaAttrs { inherit maintainers; } drv);
244 in lib.mapAttrsRecursiveCond (as: !lib.isDerivation as) (name: mkBootstrapToolsJob)
245 # The `bootstrapTools.${platform}.bootstrapTools` derivation
246 # *unpacks* the bootstrap-files using their own `busybox` binary,
247 # so it will fail unless buildPlatform.canExecute hostPlatform.
248 # Unfortunately `bootstrapTools` also clobbers its own `system`
249 # attribute, so there is no way to detect this -- we must add it
250 # as a special case. We filter the "test" attribute (only from
251 # *cross*-built bootstrapTools) for the same reason.
252 (builtins.mapAttrs (_: v: builtins.removeAttrs v ["bootstrapTools" "test"]) tools);
254 # Cross-built nixStatic for platforms for enabled-but-unsupported platforms
255 mips64el-nixCrossStatic = mapTestOnCross lib.systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;
256 powerpc64le-nixCrossStatic = mapTestOnCross lib.systems.examples.powernv nixCrossStatic;