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; }; }
24 release-lib = import ./release-lib.nix {
25 inherit supportedSystems scrubJobs nixpkgsArgs;
40 inherit (release-lib.lib)
53 inherit (release-lib.lib.attrsets)
57 nativePlatforms = all;
60 buildPackages.binutils = nativePlatforms;
61 buildPackages.gcc = nativePlatforms;
62 libcCross = nativePlatforms;
66 buildPackages.binutils = nativePlatforms;
67 gmp = nativePlatforms;
68 libcCross = nativePlatforms;
69 nix = nativePlatforms;
70 nixUnstable = nativePlatforms;
71 mesa = nativePlatforms;
72 rustc = nativePlatforms;
73 cargo = nativePlatforms;
76 gnuCommon = recursiveUpdate common {
77 buildPackages.gcc = nativePlatforms;
78 coreutils = nativePlatforms;
79 haskell.packages.ghcHEAD.hello = nativePlatforms;
80 haskellPackages.hello = nativePlatforms;
83 linuxCommon = recursiveUpdate gnuCommon {
84 buildPackages.gdb = nativePlatforms;
86 bison = nativePlatforms;
87 busybox = nativePlatforms;
88 dropbear = nativePlatforms;
90 ncurses = nativePlatforms;
91 patch = nativePlatforms;
94 windowsCommon = recursiveUpdate gnuCommon {
95 boehmgc = nativePlatforms;
96 libffi = nativePlatforms;
97 libtool = nativePlatforms;
98 libunistring = nativePlatforms;
99 windows.mingw_w64_pthreads = nativePlatforms;
103 gmp = nativePlatforms;
104 boehmgc = nativePlatforms;
105 hello = nativePlatforms;
106 zlib = nativePlatforms;
110 buildPackages.binutils = darwin;
113 rpiCommon = linuxCommon // {
114 vim = nativePlatforms;
115 unzip = nativePlatforms;
116 ddrescue = nativePlatforms;
117 lynx = nativePlatforms;
118 patchelf = nativePlatforms;
119 buildPackages.binutils = nativePlatforms;
120 mpg123 = nativePlatforms;
123 # Enabled-but-unsupported platforms for which nix is known to build.
124 # We provide Hydra-built `nixStatic` for these platforms. This
125 # allows users to bootstrap their own system without either (a)
126 # trusting binaries from a non-Hydra source or (b) having to fight
127 # with their host distribution's versions of nix's numerous
128 # build dependencies.
130 nixStatic = linux; # no need for buildPlatform=*-darwin
136 # These derivations from a cross package set's `buildPackages` should be
137 # identical to their vanilla equivalents --- none of these package should
138 # observe the target platform which is the only difference between those
140 ensureUnaffected = let
141 # Absurd values are fine here, as we are not building anything. In fact,
142 # there probably a good idea to try to be "more parametric" --- i.e. avoid
143 # any special casing.
145 config = "mips64el-apple-windows-gnu";
149 # Converting to a string (drv path) before checking equality is probably a
150 # good idea lest there be some irrelevant pass-through debug attrs that
151 # cause false negatives.
152 testEqualOne = path: system: let
153 f = path: crossSystem: system: toString (getAttrFromPath path (pkgsForCross crossSystem system));
157 f (["buildPackages"] ++ path) crossSystem system
160 testEqual = path: systems: forMatchingSystems systems (testEqualOne path);
162 mapTestEqual = mapAttrsRecursive testEqual;
165 boehmgc = nativePlatforms;
166 libffi = nativePlatforms;
167 libiconv = nativePlatforms;
168 libtool = nativePlatforms;
169 zlib = nativePlatforms;
170 readline = nativePlatforms;
171 libxml2 = nativePlatforms;
172 guile = nativePlatforms;
175 crossIphone64 = mapTestOnCross systems.examples.iphone64 darwinCommon;
177 crossIphone32 = mapTestOnCross systems.examples.iphone32 darwinCommon;
179 /* Test some cross builds to the Sheevaplug */
180 crossSheevaplugLinux = mapTestOnCross systems.examples.sheevaplug (linuxCommon // {
181 ubootSheevaplug = nativePlatforms;
184 /* Test some cross builds on 32 bit mingw-w64 */
185 crossMingw32 = mapTestOnCross systems.examples.mingw32 windowsCommon;
187 /* Test some cross builds on 64 bit mingw-w64 */
188 crossMingwW64 = mapTestOnCross systems.examples.mingwW64 windowsCommon;
190 /* Linux on mipsel */
191 fuloongminipc = mapTestOnCross systems.examples.fuloongminipc linuxCommon;
192 ben-nanonote = mapTestOnCross systems.examples.ben-nanonote linuxCommon;
195 ghcjs = mapTestOnCross systems.examples.ghcjs {
196 haskell.packages.ghcjs.hello = nativePlatforms;
197 haskell.packages.native-bignum.ghcHEAD.hello = nativePlatforms;
198 haskellPackages.hello = nativePlatforms;
201 /* Linux on Raspberrypi */
202 rpi = mapTestOnCross systems.examples.raspberryPi rpiCommon;
203 rpi-musl = mapTestOnCross systems.examples.muslpi rpiCommon;
205 /* Linux on the Remarkable */
206 remarkable1 = mapTestOnCross systems.examples.remarkable1 linuxCommon;
207 remarkable2 = mapTestOnCross systems.examples.remarkable2 linuxCommon;
209 /* Linux on armv7l-hf */
210 armv7l-hf = mapTestOnCross systems.examples.armv7l-hf-multiplatform linuxCommon;
212 pogoplug4 = mapTestOnCross systems.examples.pogoplug4 linuxCommon;
214 /* Linux on aarch64 */
215 aarch64 = mapTestOnCross systems.examples.aarch64-multiplatform linuxCommon;
216 aarch64-musl = mapTestOnCross systems.examples.aarch64-multiplatform-musl linuxCommon;
219 riscv64 = mapTestOnCross systems.examples.riscv64 linuxCommon;
220 riscv32 = mapTestOnCross systems.examples.riscv32 linuxCommon;
222 /* Linux on LoongArch */
223 loongarch64-linux = mapTestOnCross systems.examples.loongarch64-linux linuxCommon;
225 m68k = mapTestOnCross systems.examples.m68k linuxCommon;
226 s390x = mapTestOnCross systems.examples.s390x linuxCommon;
228 /* (Cross-compiled) Linux on x86 */
229 x86_64-musl = mapTestOnCross systems.examples.musl64 linuxCommon;
230 x86_64-gnu = mapTestOnCross systems.examples.gnu64 linuxCommon;
231 i686-musl = mapTestOnCross systems.examples.musl32 linuxCommon;
232 i686-gnu = mapTestOnCross systems.examples.gnu32 linuxCommon;
234 ppc64le = mapTestOnCross systems.examples.powernv linuxCommon;
235 ppc64le-musl = mapTestOnCross systems.examples.musl-power linuxCommon;
237 android64 = mapTestOnCross systems.examples.aarch64-android-prebuilt linuxCommon;
238 android32 = mapTestOnCross systems.examples.armv7a-android-prebuilt linuxCommon;
240 wasi32 = mapTestOnCross systems.examples.wasi32 wasiCommon;
242 msp430 = mapTestOnCross systems.examples.msp430 embedded;
243 mmix = mapTestOnCross systems.examples.mmix embedded;
244 vc4 = mapTestOnCross systems.examples.vc4 embedded;
245 or1k = mapTestOnCross systems.examples.or1k embedded;
246 avr = mapTestOnCross systems.examples.avr embedded;
247 arm-embedded = mapTestOnCross systems.examples.arm-embedded embedded;
248 armhf-embedded = mapTestOnCross systems.examples.armhf-embedded embedded;
249 aarch64-embedded = mapTestOnCross systems.examples.aarch64-embedded embedded;
250 aarch64be-embedded = mapTestOnCross systems.examples.aarch64be-embedded embedded;
251 powerpc-embedded = mapTestOnCross systems.examples.ppc-embedded embedded;
252 powerpcle-embedded = mapTestOnCross systems.examples.ppcle-embedded embedded;
253 i686-embedded = mapTestOnCross systems.examples.i686-embedded embedded;
254 x86_64-embedded = mapTestOnCross systems.examples.x86_64-embedded embedded;
255 riscv64-embedded = mapTestOnCross systems.examples.riscv64-embedded embedded;
256 riscv32-embedded = mapTestOnCross systems.examples.riscv32-embedded embedded;
257 rx-embedded = mapTestOnCross systems.examples.rx-embedded embedded;
259 x86_64-freebsd = mapTestOnCross systems.examples.x86_64-freebsd common;
260 x86_64-netbsd = mapTestOnCross systems.examples.x86_64-netbsd common;
261 x86_64-openbsd = mapTestOnCross systems.examples.x86_64-openbsd common;
263 # we test `embedded` instead of `linuxCommon` because very few packages
264 # successfully cross-compile to Redox so far
265 x86_64-redox = mapTestOnCross systems.examples.x86_64-unknown-redox embedded;
267 /* Cross-built bootstrap tools for every supported platform */
269 linuxTools = import ../stdenv/linux/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
270 freebsdTools = import ../stdenv/freebsd/make-bootstrap-tools-cross.nix { system = "x86_64-linux"; };
272 maintainers = [ maintainers.dezgeg ];
275 maintainers = [ maintainers.rhelmot ];
277 mkBootstrapToolsJob = meta: drv:
278 assert elem drv.system supportedSystems;
279 hydraJob' (addMetaAttrs meta drv);
280 linux = mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob linuxMeta)
281 # The `bootstrapTools.${platform}.bootstrapTools` derivation
282 # *unpacks* the bootstrap-files using their own `busybox` binary,
283 # so it will fail unless buildPlatform.canExecute hostPlatform.
284 # Unfortunately `bootstrapTools` also clobbers its own `system`
285 # attribute, so there is no way to detect this -- we must add it
286 # as a special case. We filter the "test" attribute (only from
287 # *cross*-built bootstrapTools) for the same reason.
288 (mapAttrs (_: v: removeAttrs v ["bootstrapTools" "test"]) linuxTools);
289 freebsd = mapAttrsRecursiveCond (as: !isDerivation as) (name: mkBootstrapToolsJob freebsdMeta)
293 # Cross-built nixStatic for platforms for enabled-but-unsupported platforms
294 mips64el-nixCrossStatic = mapTestOnCross systems.examples.mips64el-linux-gnuabi64 nixCrossStatic;
295 powerpc64le-nixCrossStatic = mapTestOnCross systems.examples.powernv nixCrossStatic;