From de88969f125c91309f3f565e1c435b4f2021e770 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Mon, 5 Sep 2022 22:02:30 -0700 Subject: lib/systems: fix uname.processor for powerpc{32,64}, mips64 Cross-compilation of anything downstream of gtk3 requires qemu (due to gobject-introspection) with --target-list=*-linux-user. Without this commit, those qemu builds will fail on a powerpc64le host due to qemu being configured with --cpu=powerpc64le instead of --cpu=ppc64le. Unfortunately the build failure message from qemu in this situation is extremely cryptic. The root cause turns out not to be the qemu expression, but rather the fact that on powerpc64le hostPlatform.uname.processor returns the gnu-name (powerpc64le) for the cpu instead of the linux-name (ppc64le) for the cpu. uname.processor on mips64el also needs adjustment -- the Linux-name is "mips64" for both big and little endian (unlike powerpc64, where the Linux-name includes a "le" suffix): ``` nix@oak:/tmp$ uname -m; lscpu | head -n2 mips64 Architecture: mips64 Byte Order: Little Endian ``` uname.processor on powerpc32 has also been adjusted. --- lib/systems/default.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'lib/systems/default.nix') diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 4c1e9d9f25364..4a5e66caec7c4 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -101,7 +101,14 @@ rec { }.${final.parsed.kernel.name} or null; # uname -m - processor = final.parsed.cpu.name; + processor = + if final.isPower64 + then "ppc64${lib.optionalString final.isLittleEndian "le"}" + else if final.isPower + then "ppc${lib.optionalString final.isLittleEndian "le"}" + else if final.isMips64 + then "mips64" # endianness is *not* included on mips64 + else final.parsed.cpu.name; # uname -r release = null; @@ -135,12 +142,7 @@ rec { if final.isAarch32 then "arm" else if final.isx86_64 then "x86_64" else if final.isx86 then "i386" - else { - powerpc = "ppc"; - powerpcle = "ppc"; - powerpc64 = "ppc64"; - powerpc64le = "ppc64le"; - }.${final.parsed.cpu.name} or final.parsed.cpu.name; + else final.uname.processor; # Name used by UEFI for architectures. efiArch = -- cgit 1.4.1