git.iko.soy/typeable/nixpkgs
on master help sign in
lib.systems: add powerpc64-linux

PPC64 supports two ABIs: ELF v1 and v2. ELFv1 is historically what GCC and most packages expect, but this is changing because musl outright does not work with ELFv1. So any distro which uses musl must use ELFv2. Many other platforms are moving to ELFv2 too, such as FreeBSD (as of v13) and Gentoo (as of late 2020). Since we use musl extensively, let's default to ELFv2. Nix gives us the power to specify this declaratively for the entire system, so ELFv1 is not dropped entirely. It can be specified explicitly in the target config, e.g. "powerpc64-unknown-linux-elfv1". Otherwise the default is "powerpc64-unknown-linux-elfv2". For musl, "powerpc64-unknown-linux-musl" must use elfv2 internally to function.

commit72b3badb6197a042c52397fcea467f630628c75c authorRyan Burns <rtburns@protonmail.com> dateFri 29 Jan 2021, 19:23 (6 years ago) parent054f792
4 files changed+26−3
lib/systems/doubles.nix+3−2 lib/systems/examples.nix+13 lib/systems/parse.nix+9 lib/tests/systems.nix+1−1
lib/systems/doubles.nix+3−2
@@ -24,6 +24,7 @@ let
2424
2525 "x86_64-redox"
2626
27+ "powerpc64-linux"
2728 "powerpc64le-linux"
2829
2930 "riscv32-linux" "riscv64-linux"
@@ -72,7 +73,7 @@ in {
7273 darwin = filterDoubles predicates.isDarwin;
7374 freebsd = filterDoubles predicates.isFreeBSD;
7475 # Should be better, but MinGW is unclear.
75− gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; });
76+ gnu = filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnu; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabi; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnueabihf; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.elfv1; }) ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.elfv2; });
7677 illumos = filterDoubles predicates.isSunOS;
7778 linux = filterDoubles predicates.isLinux;
7879 netbsd = filterDoubles predicates.isNetBSD;
@@ -85,5 +86,5 @@ in {
8586
8687 embedded = filterDoubles predicates.isNone;
8788
88− mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "armv7a-linux" "aarch64-linux" "powerpc64le-linux"];
89+ mesaPlatforms = ["i686-linux" "x86_64-linux" "x86_64-darwin" "armv5tel-linux" "armv6l-linux" "armv7l-linux" "armv7a-linux" "aarch64-linux" "powerpc64-linux" "powerpc64le-linux"];
8990}
lib/systems/examples.nix+13
@@ -21,6 +21,19 @@ rec {
2121 config = "powerpc64le-unknown-linux-musl";
2222 };
2323
24+ ppc64-elfv1 = {
25+ config = "powerpc64-unknown-linux-elfv1";
26+ };
27+ ppc64-elfv2 = {
28+ config = "powerpc64-unknown-linux-elfv2";
29+ };
30+ ppc64 = ppc64-elfv2; # default to modern elfv2
31+
32+ ppc64-musl = {
33+ config = "powerpc64-unknown-linux-musl";
34+ gcc = { abi = "elfv2"; }; # for gcc configuration
35+ };
36+
2437 sheevaplug = {
2538 config = "armv5tel-unknown-linux-gnueabi";
2639 } // platforms.sheevaplug;
lib/systems/parse.nix+9
@@ -337,10 +337,18 @@ rec {
337337 The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead.
338338 '';
339339 }
340+ { assertion = platform: platform.system != "powerpc64-linux";
341+ message = ''
342+ The "gnu" ABI is ambiguous on big-endian 64-bit PPC. Use "elfv1" or "elfv2" instead.
343+ '';
344+ }
340345 ];
341346 };
342347 gnuabi64 = { abi = "64"; };
343348
349+ elfv1 = { abi = "elfv1"; };
350+ elfv2 = { abi = "elfv2"; };
351+
344352 musleabi = { float = "soft"; };
345353 musleabihf = { float = "hard"; };
346354 musl = {};
@@ -444,6 +452,7 @@ rec {
444452 if lib.versionAtLeast (parsed.cpu.version or "0") "6"
445453 then abis.gnueabihf
446454 else abis.gnueabi
455+ else if cpu == "powerpc64" then abis.elfv2
447456 else abis.gnu
448457 else abis.unknown;
449458 };
lib/tests/systems.nix+1−1
@@ -28,7 +28,7 @@ with lib.systems.doubles; lib.runTests {
2828 testredox = mseteq redox [ "x86_64-redox" ];
2929 testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */);
3030 testillumos = mseteq illumos [ "x86_64-solaris" ];
31− testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64le-linux" ];
31+ testlinux = mseteq linux [ "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "mipsel-linux" "riscv32-linux" "riscv64-linux" "x86_64-linux" "powerpc64-linux" "powerpc64le-linux" ];
3232 testnetbsd = mseteq netbsd [ "i686-netbsd" "x86_64-netbsd" ];
3333 testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ];
3434 testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];