1# These can be passed to nixpkgs as either the `localSystem` or
2# `crossSystem`. They are put here for user convenience, but also used by cross
3# tests and linux cross stdenv building, so handle with care!
4{ lib }:
5let
6 platforms = import ./platforms.nix { inherit lib; };
7
8 riscv = bits: {
9 config = "riscv${bits}-unknown-linux-gnu";
10 };
11in
12
13rec {
14 #
15 # Linux
16 #
17 powernv = {
18 config = "powerpc64le-unknown-linux-gnu";
19 };
20 musl-power = {
21 config = "powerpc64le-unknown-linux-musl";
22 };
23
24 ppc64-elfv1 = {
25 config = "powerpc64-unknown-linux-gnuabielfv1";
26 rust.rustcTarget = "powerpc64-unknown-linux-gnu";
27 };
28 ppc64-elfv2 = {
29 config = "powerpc64-unknown-linux-gnuabielfv2";
30 };
31 ppc64 = ppc64-elfv2;
32 ppc64-musl = {
33 config = "powerpc64-unknown-linux-musl";
34 gcc = {
35 abi = "elfv2";
36 };
37 };
38
39 sheevaplug = {
40 config = "armv5tel-unknown-linux-gnueabi";
41 }
42 // platforms.sheevaplug;
43
44 raspberryPi = {
45 config = "armv6l-unknown-linux-gnueabihf";
46 }
47 // platforms.raspberrypi;
48
49 bluefield2 = {
50 config = "aarch64-unknown-linux-gnu";
51 }
52 // platforms.bluefield2;
53
54 remarkable1 = {
55 config = "armv7l-unknown-linux-gnueabihf";
56 }
57 // platforms.zero-gravitas;
58
59 remarkable2 = {
60 config = "armv7l-unknown-linux-gnueabihf";
61 }
62 // platforms.zero-sugar;
63
64 armv7l-hf-multiplatform = {
65 config = "armv7l-unknown-linux-gnueabihf";
66 };
67
68 aarch64-multiplatform = {
69 config = "aarch64-unknown-linux-gnu";
70 };
71
72 armv7a-android-prebuilt = {
73 config = "armv7a-unknown-linux-androideabi";
74 rust.rustcTarget = "armv7-linux-androideabi";
75 androidSdkVersion = "33";
76 androidNdkVersion = "26";
77 useAndroidPrebuilt = true;
78 }
79 // platforms.armv7a-android;
80
81 aarch64-android-prebuilt = {
82 config = "aarch64-unknown-linux-android";
83 rust.rustcTarget = "aarch64-linux-android";
84 androidSdkVersion = "33";
85 androidNdkVersion = "26";
86 useAndroidPrebuilt = true;
87 };
88
89 aarch64-android = {
90 config = "aarch64-unknown-linux-android";
91 androidSdkVersion = "33";
92 androidNdkVersion = "26";
93 libc = "bionic";
94 useAndroidPrebuilt = false;
95 useLLVM = true;
96 };
97
98 pogoplug4 = {
99 config = "armv5tel-unknown-linux-gnueabi";
100 }
101 // platforms.pogoplug4;
102
103 ben-nanonote = {
104 config = "mipsel-unknown-linux-uclibc";
105 }
106 // platforms.ben_nanonote;
107
108 fuloongminipc = {
109 config = "mipsel-unknown-linux-gnu";
110 }
111 // platforms.fuloong2f_n32;
112
113 # can execute on 32bit chip
114 mips-linux-gnu = {
115 config = "mips-unknown-linux-gnu";
116 }
117 // platforms.gcc_mips32r2_o32;
118 mipsel-linux-gnu = {
119 config = "mipsel-unknown-linux-gnu";
120 }
121 // platforms.gcc_mips32r2_o32;
122
123 # require 64bit chip (for more registers, 64-bit floating point, 64-bit "long long") but use 32bit pointers
124 mips64-linux-gnuabin32 = {
125 config = "mips64-unknown-linux-gnuabin32";
126 }
127 // platforms.gcc_mips64r2_n32;
128 mips64el-linux-gnuabin32 = {
129 config = "mips64el-unknown-linux-gnuabin32";
130 }
131 // platforms.gcc_mips64r2_n32;
132
133 # 64bit pointers
134 mips64-linux-gnuabi64 = {
135 config = "mips64-unknown-linux-gnuabi64";
136 }
137 // platforms.gcc_mips64r2_64;
138 mips64el-linux-gnuabi64 = {
139 config = "mips64el-unknown-linux-gnuabi64";
140 }
141 // platforms.gcc_mips64r2_64;
142
143 muslpi = raspberryPi // {
144 config = "armv6l-unknown-linux-musleabihf";
145 };
146
147 aarch64-multiplatform-musl = {
148 config = "aarch64-unknown-linux-musl";
149 };
150
151 gnu64 = {
152 config = "x86_64-unknown-linux-gnu";
153 };
154 gnu64_simplekernel = gnu64 // platforms.pc_simplekernel; # see test/cross/default.nix
155 gnu32 = {
156 config = "i686-unknown-linux-gnu";
157 };
158
159 musl64 = {
160 config = "x86_64-unknown-linux-musl";
161 };
162 musl32 = {
163 config = "i686-unknown-linux-musl";
164 };
165
166 riscv64 = riscv "64";
167 riscv32 = riscv "32";
168
169 riscv64-musl = {
170 config = "riscv64-unknown-linux-musl";
171 };
172
173 riscv64-embedded = {
174 config = "riscv64-none-elf";
175 libc = "newlib";
176 };
177
178 riscv32-embedded = {
179 config = "riscv32-none-elf";
180 libc = "newlib";
181 };
182
183 mips64-embedded = {
184 config = "mips64-none-elf";
185 libc = "newlib";
186 };
187
188 mips-embedded = {
189 config = "mips-none-elf";
190 libc = "newlib";
191 };
192
193 # https://github.com/loongson/la-softdev-convention/blob/master/la-softdev-convention.adoc#10-operating-system-package-build-requirements
194 loongarch64-linux = lib.recursiveUpdate platforms.loongarch64-multiplatform {
195 config = "loongarch64-unknown-linux-gnu";
196 };
197 loongarch64-linux-embedded = lib.recursiveUpdate platforms.loongarch64-multiplatform {
198 config = "loongarch64-unknown-linux-gnu";
199 gcc = {
200 arch = "loongarch64";
201 strict-align = true;
202 };
203 };
204
205 mmix = {
206 config = "mmix-unknown-mmixware";
207 libc = "newlib";
208 };
209
210 rx-embedded = {
211 config = "rx-none-elf";
212 libc = "newlib";
213 };
214
215 msp430 = {
216 config = "msp430-elf";
217 libc = "newlib";
218 };
219
220 avr = {
221 config = "avr";
222 };
223
224 vc4 = {
225 config = "vc4-elf";
226 libc = "newlib";
227 };
228
229 or1k = {
230 config = "or1k-elf";
231 libc = "newlib";
232 };
233
234 m68k = {
235 config = "m68k-unknown-linux-gnu";
236 };
237
238 s390 = {
239 config = "s390-unknown-linux-gnu";
240 };
241
242 s390x = {
243 config = "s390x-unknown-linux-gnu";
244 };
245
246 arm-embedded = {
247 config = "arm-none-eabi";
248 libc = "newlib";
249 };
250 arm-embedded-nano = {
251 config = "arm-none-eabi";
252 libc = "newlib-nano";
253 };
254 armhf-embedded = {
255 config = "arm-none-eabihf";
256 libc = "newlib";
257 # GCC8+ does not build without this
258 # (https://www.mail-archive.com/gcc-bugs@gcc.gnu.org/msg552339.html):
259 gcc = {
260 arch = "armv5t";
261 fpu = "vfp";
262 };
263 };
264
265 aarch64-embedded = {
266 config = "aarch64-none-elf";
267 libc = "newlib";
268 rust.rustcTarget = "aarch64-unknown-none";
269 };
270
271 aarch64be-embedded = {
272 config = "aarch64_be-none-elf";
273 libc = "newlib";
274 };
275
276 ppc-embedded = {
277 config = "powerpc-none-eabi";
278 libc = "newlib";
279 };
280
281 ppcle-embedded = {
282 config = "powerpcle-none-eabi";
283 libc = "newlib";
284 };
285
286 i686-embedded = {
287 config = "i686-elf";
288 libc = "newlib";
289 };
290
291 x86_64-embedded = {
292 config = "x86_64-elf";
293 libc = "newlib";
294 };
295
296 microblaze-embedded = {
297 config = "microblazeel-none-elf";
298 libc = "newlib";
299 };
300
301 #
302 # Redox
303 #
304
305 x86_64-unknown-redox = {
306 config = "x86_64-unknown-redox";
307 libc = "relibc";
308 };
309
310 #
311 # Darwin
312 #
313
314 iphone64 = {
315 config = "arm64-apple-ios";
316 # config = "aarch64-apple-darwin14";
317 darwinSdkVersion = "14.3";
318 xcodeVer = "12.3";
319 xcodePlatform = "iPhoneOS";
320 useiOSPrebuilt = true;
321 };
322
323 iphone64-simulator = {
324 config = "x86_64-apple-ios";
325 # config = "x86_64-apple-darwin14";
326 darwinSdkVersion = "14.3";
327 xcodeVer = "12.3";
328 xcodePlatform = "iPhoneSimulator";
329 darwinPlatform = "ios-simulator";
330 useiOSPrebuilt = true;
331 };
332
333 aarch64-darwin = {
334 config = "arm64-apple-darwin";
335 xcodePlatform = "MacOSX";
336 platform = { };
337 };
338
339 x86_64-darwin = {
340 config = "x86_64-apple-darwin";
341 xcodePlatform = "MacOSX";
342 platform = { };
343 };
344
345 #
346 # Windows
347 #
348
349 # 32 bit mingw-w64
350 mingw32 = {
351 config = "i686-w64-mingw32";
352 libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
353 };
354
355 # 64 bit mingw-w64
356 mingwW64 = {
357 # That's the triplet they use in the mingw-w64 docs.
358 config = "x86_64-w64-mingw32";
359 libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain
360 };
361
362 ucrt64 = {
363 config = "x86_64-w64-mingw32";
364 libc = "ucrt"; # This distinguishes the mingw (non posix) toolchain
365 };
366
367 # LLVM-based mingw-w64 for ARM
368 ucrtAarch64 = {
369 config = "aarch64-w64-mingw32";
370 libc = "ucrt";
371 rust.rustcTarget = "aarch64-pc-windows-gnullvm";
372 useLLVM = true;
373 };
374
375 # Target the MSVC ABI
376 x86_64-windows = {
377 config = "x86_64-pc-windows-msvc";
378 useLLVM = true;
379 };
380
381 aarch64-windows = {
382 config = "aarch64-pc-windows-msvc";
383 useLLVM = true;
384 };
385
386 # BSDs
387
388 aarch64-freebsd = {
389 config = "aarch64-unknown-freebsd";
390 useLLVM = true;
391 };
392
393 x86_64-freebsd = {
394 config = "x86_64-unknown-freebsd";
395 useLLVM = true;
396 };
397
398 x86_64-netbsd = {
399 config = "x86_64-unknown-netbsd";
400 };
401
402 # this is broken and never worked fully
403 x86_64-netbsd-llvm = {
404 config = "x86_64-unknown-netbsd";
405 useLLVM = true;
406 };
407
408 x86_64-openbsd = {
409 config = "x86_64-unknown-openbsd";
410 useLLVM = true;
411 };
412
413 #
414 # WASM
415 #
416
417 wasi32 = {
418 config = "wasm32-unknown-wasi";
419 useLLVM = true;
420 };
421
422 wasm32-unknown-none = {
423 config = "wasm32-unknown-none";
424 rust.rustcTarget = "wasm32-unknown-unknown";
425 useLLVM = true;
426 };
427
428 # Ghcjs
429 ghcjs = {
430 # This triple is special to GHC/Cabal/GHCJS and not recognized by autotools
431 # See: https://gitlab.haskell.org/ghc/ghc/-/commit/6636b670233522f01d002c9b97827d00289dbf5c
432 # https://github.com/ghcjs/ghcjs/issues/53
433 config = "javascript-unknown-ghcjs";
434 };
435}