From 34e468dc4268cee86aa019ae9bc52768e60fb5f7 Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Tue, 7 Sep 2021 10:10:38 +0100 Subject: [PATCH] lib/systems: add minimal s390x-linux cross-compile support Tested basic functionality as: $ nix-build --arg crossSystem '{ config = "s390x-unknown-linux-gnu"; }' -A re2c $ file ./result/bin/re2c $ ./result/bin/re2c: ELF 64-bit MSB executable, IBM S/390, version 1 (SYSV), dynamically linked, interpreter ...-gnu-2.33-50/lib/ld64.so.1, for GNU/Linux 2.6.32, not stripped $ qemu-s390x ./result/bin/re2c --version re2c 2.2 --- lib/systems/default.nix | 1 + lib/systems/doubles.nix | 5 +++-- lib/systems/examples.nix | 4 ++++ lib/systems/parse.nix | 1 + lib/tests/systems.nix | 2 +- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/systems/default.nix b/lib/systems/default.nix index 70ec98b03c16..ef609859abbf 100644 --- a/lib/systems/default.nix +++ b/lib/systems/default.nix @@ -107,6 +107,7 @@ rec { else if final.isMips then "mips" else if final.isPower then "powerpc" else if final.isRiscV then "riscv" + else if final.isS390 then "s390" else final.parsed.cpu.name; qemuArch = diff --git a/lib/systems/doubles.nix b/lib/systems/doubles.nix index e577059687b0..8af3377fb5bf 100644 --- a/lib/systems/doubles.nix +++ b/lib/systems/doubles.nix @@ -28,7 +28,7 @@ let "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" "armv7l-linux" "i686-linux" "m68k-linux" "mipsel-linux" "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" - "riscv64-linux" "s390-linux" "x86_64-linux" + "riscv64-linux" "s390-linux" "s390x-linux" "x86_64-linux" # MMIXware "mmix-mmixware" @@ -41,7 +41,8 @@ let # none "aarch64-none" "arm-none" "armv6l-none" "avr-none" "i686-none" "msp430-none" "or1k-none" "m68k-none" "powerpc-none" - "riscv32-none" "riscv64-none" "s390-none" "vc4-none" "x86_64-none" + "riscv32-none" "riscv64-none" "s390-none" "s390x-none" "vc4-none" + "x86_64-none" # OpenBSD "i686-openbsd" "x86_64-openbsd" diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 32b236d6960c..8dfa22ac787e 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -152,6 +152,10 @@ rec { config = "s390-unknown-linux-gnu"; }; + s390x = { + config = "s390x-unknown-linux-gnu"; + }; + arm-embedded = { config = "arm-none-eabi"; libc = "newlib"; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 77e941a913cf..8a88d8cfbe87 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -106,6 +106,7 @@ rec { riscv64 = { bits = 64; significantByte = littleEndian; family = "riscv"; }; s390 = { bits = 32; significantByte = bigEndian; family = "s390"; }; + s390x = { bits = 64; significantByte = bigEndian; family = "s390"; }; sparc = { bits = 32; significantByte = bigEndian; family = "sparc"; }; sparc64 = { bits = 64; significantByte = bigEndian; family = "sparc"; }; diff --git a/lib/tests/systems.nix b/lib/tests/systems.nix index 661b9bc8690c..2646e792682b 100644 --- a/lib/tests/systems.nix +++ b/lib/tests/systems.nix @@ -28,7 +28,7 @@ with lib.systems.doubles; lib.runTests { testredox = mseteq redox [ "x86_64-redox" ]; testgnu = mseteq gnu (linux /* ++ kfreebsd ++ ... */); testillumos = mseteq illumos [ "x86_64-solaris" ]; - 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" "m68k-linux" "s390-linux" ]; + 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" "m68k-linux" "s390-linux" "s390x-linux" ]; testnetbsd = mseteq netbsd [ "aarch64-netbsd" "armv6l-netbsd" "armv7a-netbsd" "armv7l-netbsd" "i686-netbsd" "m68k-netbsd" "mipsel-netbsd" "powerpc-netbsd" "riscv32-netbsd" "riscv64-netbsd" "x86_64-netbsd" ]; testopenbsd = mseteq openbsd [ "i686-openbsd" "x86_64-openbsd" ]; testwindows = mseteq windows [ "i686-cygwin" "x86_64-cygwin" "i686-windows" "x86_64-windows" ];