diff options
author | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2023-06-16 06:56:35 +0000 |
commit | 99fcaeccb89621dd492203ce1f2d551c06f228ed (patch) | |
tree | 41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/lib/systems | |
parent | 59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff) | |
parent | 75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff) | |
download | nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2 nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip |
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts: nixpkgs/nixos/modules/config/console.nix nixpkgs/nixos/modules/services/mail/mailman.nix nixpkgs/nixos/modules/services/mail/public-inbox.nix nixpkgs/nixos/modules/services/mail/rss2email.nix nixpkgs/nixos/modules/services/networking/ssh/sshd.nix nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix nixpkgs/pkgs/applications/networking/irc/weechat/default.nix nixpkgs/pkgs/applications/window-managers/sway/default.nix nixpkgs/pkgs/build-support/go/module.nix nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix nixpkgs/pkgs/development/interpreters/python/default.nix nixpkgs/pkgs/development/node-packages/overrides.nix nixpkgs/pkgs/development/tools/b4/default.nix nixpkgs/pkgs/servers/dict/dictd-db.nix nixpkgs/pkgs/servers/mail/public-inbox/default.nix nixpkgs/pkgs/tools/security/pinentry/default.nix nixpkgs/pkgs/tools/text/unoconv/default.nix nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/lib/systems')
-rw-r--r-- | nixpkgs/lib/systems/architectures.nix | 21 | ||||
-rw-r--r-- | nixpkgs/lib/systems/default.nix | 118 | ||||
-rw-r--r-- | nixpkgs/lib/systems/doubles.nix | 24 | ||||
-rw-r--r-- | nixpkgs/lib/systems/examples.nix | 39 | ||||
-rw-r--r-- | nixpkgs/lib/systems/flake-systems.nix | 2 | ||||
-rw-r--r-- | nixpkgs/lib/systems/inspect.nix | 47 | ||||
-rw-r--r-- | nixpkgs/lib/systems/parse.nix | 89 | ||||
-rw-r--r-- | nixpkgs/lib/systems/platforms.nix | 2 |
8 files changed, 221 insertions, 121 deletions
diff --git a/nixpkgs/lib/systems/architectures.nix b/nixpkgs/lib/systems/architectures.nix index ddc320d24e0a..57b9184ca60c 100644 --- a/nixpkgs/lib/systems/architectures.nix +++ b/nixpkgs/lib/systems/architectures.nix @@ -40,14 +40,21 @@ rec { # a superior CPU has all the features of an inferior and is able to build and test code for it inferiors = { # x86_64 Intel + # https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html default = [ ]; westmere = [ ]; - sandybridge = [ "westmere" ] ++ inferiors.westmere; - ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge; - haswell = [ "ivybridge" ] ++ inferiors.ivybridge; - broadwell = [ "haswell" ] ++ inferiors.haswell; - skylake = [ "broadwell" ] ++ inferiors.broadwell; - skylake-avx512 = [ "skylake" ] ++ inferiors.skylake; + sandybridge = [ "westmere" ] ++ inferiors.westmere; + ivybridge = [ "sandybridge" ] ++ inferiors.sandybridge; + haswell = [ "ivybridge" ] ++ inferiors.ivybridge; + broadwell = [ "haswell" ] ++ inferiors.haswell; + skylake = [ "broadwell" ] ++ inferiors.broadwell; + skylake-avx512 = [ "skylake" ] ++ inferiors.skylake; + cannonlake = [ "skylake-avx512" ] ++ inferiors.skylake-avx512; + icelake-client = [ "cannonlake" ] ++ inferiors.cannonlake; + icelake-server = [ "icelake-client" ] ++ inferiors.icelake-client; + cascadelake = [ "skylake-avx512" ] ++ inferiors.cannonlake; + cooperlake = [ "cascadelake" ] ++ inferiors.cascadelake; + tigerlake = [ "icelake-server" ] ++ inferiors.icelake-server; # x86_64 AMD # TODO: fill this (need testing) @@ -67,7 +74,7 @@ rec { # # Note: # - # - The succesors of `skylake` (`cannonlake`, `icelake`, etc) use `avx512` + # - The successors of `skylake` (`cannonlake`, `icelake`, etc) use `avx512` # which no current AMD Zen michroarch support. # - `znver1` uses `ABM`, `CLZERO`, `CX16`, `MWAITX`, and `SSE4A` which no # current Intel microarch support. diff --git a/nixpkgs/lib/systems/default.nix b/nixpkgs/lib/systems/default.nix index 2990afde3e9a..f4784c61c675 100644 --- a/nixpkgs/lib/systems/default.nix +++ b/nixpkgs/lib/systems/default.nix @@ -20,7 +20,7 @@ rec { # necessary. # # `parsed` is inferred from args, both because there are two options with one - # clearly prefered, and to prevent cycles. A simpler fixed point where the RHS + # clearly preferred, and to prevent cycles. A simpler fixed point where the RHS # always just used `final.*` would fail on both counts. elaborate = args': let args = if lib.isString args' then { system = args'; } @@ -47,9 +47,11 @@ rec { else if final.isUClibc then "uclibc" else if final.isAndroid then "bionic" else if final.isLinux /* default */ then "glibc" + else if final.isFreeBSD then "fblibc" + else if final.isNetBSD then "nblibc" else if final.isAvr then "avrlibc" + else if final.isGhcjs then null else if final.isNone then "newlib" - else if final.isNetBSD then "nblibc" # TODO(@Ericson2314) think more about other operating systems else "native/impure"; # Choose what linker we wish to use by default. Someday we might also @@ -61,15 +63,21 @@ rec { linker = /**/ if final.useLLVM or false then "lld" else if final.isDarwin then "cctools" - # "bfd" and "gold" both come from GNU binutils. The existance of Gold + # "bfd" and "gold" both come from GNU binutils. The existence of Gold # is why we use the more obscure "bfd" and not "binutils" for this # choice. else "bfd"; - extensions = { + extensions = rec { sharedLibrary = /**/ if final.isDarwin then ".dylib" else if final.isWindows then ".dll" else ".so"; + staticLibrary = + /**/ if final.isWindows then ".lib" + else ".a"; + library = + /**/ if final.isStatic then staticLibrary + else sharedLibrary; executable = /**/ if final.isWindows then ".exe" else ""; @@ -93,8 +101,15 @@ rec { genode = "Genode"; }.${final.parsed.kernel.name} or null; - # uname -p - processor = final.parsed.cpu.name; + # uname -m + 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; @@ -106,7 +121,7 @@ rec { ({ linux-kernel = args.linux-kernel or {}; gcc = args.gcc or {}; - rustc = args.rust or {}; + rustc = args.rustc or {}; } // platforms.select final) linux-kernel gcc rustc; @@ -115,23 +130,31 @@ rec { else if final.isAarch64 then "arm64" else if final.isx86_32 then "i386" else if final.isx86_64 then "x86_64" + # linux kernel does not distinguish microblaze/microblazeel + else if final.isMicroBlaze then "microblaze" else if final.isMips32 then "mips" else if final.isMips64 then "mips" # linux kernel does not distinguish mips32/mips64 else if final.isPower then "powerpc" else if final.isRiscV then "riscv" else if final.isS390 then "s390" + else if final.isLoongArch64 then "loongarch" else final.parsed.cpu.name; qemuArch = if final.isAarch32 then "arm" + else if final.isS390 && !final.isS390x then null 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 if final.isMips64 then "mips64${lib.optionalString final.isLittleEndian "el"}" + else final.uname.processor; + + # Name used by UEFI for architectures. + efiArch = + if final.isx86_32 then "ia32" + else if final.isx86_64 then "x64" + else if final.isAarch32 then "arm" + else if final.isAarch64 then "aa64" + else final.parsed.cpu.name; darwinArch = { armv7a = "armv7"; @@ -150,38 +173,47 @@ rec { if final.isMacOS then "MACOSX_DEPLOYMENT_TARGET" else if final.isiOS then "IPHONEOS_DEPLOYMENT_TARGET" else null; + } // ( + let + selectEmulator = pkgs: + let + qemu-user = pkgs.qemu.override { + smartcardSupport = false; + spiceSupport = false; + openGLSupport = false; + virglSupport = false; + vncSupport = false; + gtkSupport = false; + sdlSupport = false; + pulseSupport = false; + smbdSupport = false; + seccompSupport = false; + enableDocs = false; + hostCpuTargets = [ "${final.qemuArch}-linux-user" ]; + }; + wine = (pkgs.winePackagesFor "wine${toString final.parsed.cpu.bits}").minimal; + in + if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name && + pkgs.stdenv.hostPlatform.canExecute final + then "${pkgs.runtimeShell} -c '\"$@\"' --" + else if final.isWindows + then "${wine}/bin/wine${lib.optionalString (final.parsed.cpu.bits == 64) "64"}" + else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux && final.qemuArch != null + then "${qemu-user}/bin/qemu-${final.qemuArch}" + else if final.isWasi + then "${pkgs.wasmtime}/bin/wasmtime" + else if final.isMmix + then "${pkgs.mmixware}/bin/mmix" + else null; + in { + emulatorAvailable = pkgs: (selectEmulator pkgs) != null; - emulator = pkgs: let - qemu-user = pkgs.qemu.override { - smartcardSupport = false; - spiceSupport = false; - openGLSupport = false; - virglSupport = false; - vncSupport = false; - gtkSupport = false; - sdlSupport = false; - pulseSupport = false; - smbdSupport = false; - seccompSupport = false; - hostCpuTargets = ["${final.qemuArch}-linux-user"]; - }; - wine-name = "wine${toString final.parsed.cpu.bits}"; - wine = (pkgs.winePackagesFor wine-name).minimal; - in - if final.parsed.kernel.name == pkgs.stdenv.hostPlatform.parsed.kernel.name && - pkgs.stdenv.hostPlatform.canExecute final - then "${pkgs.runtimeShell} -c '\"$@\"' --" - else if final.isWindows - then "${wine}/bin/${wine-name}" - else if final.isLinux && pkgs.stdenv.hostPlatform.isLinux - then "${qemu-user}/bin/qemu-${final.qemuArch}" - else if final.isWasi - then "${pkgs.wasmtime}/bin/wasmtime" - else if final.isMmix - then "${pkgs.mmixware}/bin/mmix" - else throw "Don't know how to run ${final.config} executables."; + emulator = pkgs: + if (final.emulatorAvailable pkgs) + then selectEmulator pkgs + else throw "Don't know how to run ${final.config} executables."; - } // mapAttrs (n: v: v final.parsed) inspect.predicates + }) // mapAttrs (n: v: v final.parsed) inspect.predicates // mapAttrs (n: v: v final.gcc.arch or "default") architectures.predicates // args; in assert final.useAndroidPrebuilt -> final.isAndroid; diff --git a/nixpkgs/lib/systems/doubles.nix b/nixpkgs/lib/systems/doubles.nix index 90a6eb9f35c9..66bf3d872bee 100644 --- a/nixpkgs/lib/systems/doubles.nix +++ b/nixpkgs/lib/systems/doubles.nix @@ -13,7 +13,7 @@ let "x86_64-darwin" "i686-darwin" "aarch64-darwin" "armv7a-darwin" # FreeBSD - "i686-freebsd" "x86_64-freebsd" + "i686-freebsd13" "x86_64-freebsd13" # Genode "aarch64-genode" "i686-genode" "x86_64-genode" @@ -22,12 +22,13 @@ let "x86_64-solaris" # JS - "js-ghcjs" + "javascript-ghcjs" # Linux "aarch64-linux" "armv5tel-linux" "armv6l-linux" "armv7a-linux" - "armv7l-linux" "i686-linux" "m68k-linux" "mipsel-linux" "mips64el-linux" - "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" + "armv7l-linux" "i686-linux" "loongarch64-linux" "m68k-linux" "microblaze-linux" + "microblazeel-linux" "mips-linux" "mips64-linux" "mips64el-linux" + "mipsel-linux" "powerpc64-linux" "powerpc64le-linux" "riscv32-linux" "riscv64-linux" "s390-linux" "s390x-linux" "x86_64-linux" # MMIXware @@ -40,9 +41,9 @@ let # none "aarch64_be-none" "aarch64-none" "arm-none" "armv6l-none" "avr-none" "i686-none" - "msp430-none" "or1k-none" "m68k-none" "powerpc-none" "powerpcle-none" - "riscv32-none" "riscv64-none" "rx-none" "s390-none" "s390x-none" "vc4-none" - "x86_64-none" + "microblaze-none" "microblazeel-none" "msp430-none" "or1k-none" "m68k-none" + "powerpc-none" "powerpcle-none" "riscv32-none" "riscv64-none" "rx-none" + "s390-none" "s390x-none" "vc4-none" "x86_64-none" # OpenBSD "i686-openbsd" "x86_64-openbsd" @@ -67,12 +68,15 @@ in { none = []; arm = filterDoubles predicates.isAarch32; + armv7 = filterDoubles predicates.isArmv7; aarch64 = filterDoubles predicates.isAarch64; x86 = filterDoubles predicates.isx86; i686 = filterDoubles predicates.isi686; x86_64 = filterDoubles predicates.isx86_64; + microblaze = filterDoubles predicates.isMicroBlaze; mips = filterDoubles predicates.isMips; mmix = filterDoubles predicates.isMmix; + power = filterDoubles predicates.isPower; riscv = filterDoubles predicates.isRiscV; riscv32 = filterDoubles predicates.isRiscV32; riscv64 = filterDoubles predicates.isRiscV64; @@ -81,6 +85,8 @@ in { or1k = filterDoubles predicates.isOr1k; m68k = filterDoubles predicates.isM68k; s390 = filterDoubles predicates.isS390; + s390x = filterDoubles predicates.isS390x; + loongarch64 = filterDoubles predicates.isLoongArch64; js = filterDoubles predicates.isJavaScript; bigEndian = filterDoubles predicates.isBigEndian; @@ -94,7 +100,9 @@ in { ++ 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.gnuabin32; }) - ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; }); + ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabi64; }) + ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv1; }) + ++ filterDoubles (matchAttrs { kernel = parse.kernels.linux; abi = parse.abis.gnuabielfv2; }); illumos = filterDoubles predicates.isSunOS; linux = filterDoubles predicates.isLinux; netbsd = filterDoubles predicates.isNetBSD; diff --git a/nixpkgs/lib/systems/examples.nix b/nixpkgs/lib/systems/examples.nix index 65dc9c07e346..45b95c150fce 100644 --- a/nixpkgs/lib/systems/examples.nix +++ b/nixpkgs/lib/systems/examples.nix @@ -22,12 +22,11 @@ rec { }; ppc64 = { - config = "powerpc64-unknown-linux-gnu"; - gcc = { abi = "elfv2"; }; # for gcc configuration + config = "powerpc64-unknown-linux-gnuabielfv2"; }; ppc64-musl = { config = "powerpc64-unknown-linux-musl"; - gcc = { abi = "elfv2"; }; # for gcc configuration + gcc = { abi = "elfv2"; }; }; sheevaplug = { @@ -92,22 +91,16 @@ rec { } // platforms.fuloong2f_n32; # can execute on 32bit chip - mips-linux-gnu = { config = "mips-unknown-linux-gnu"; } // platforms.gcc_mips32r2_o32; - mipsel-linux-gnu = { config = "mipsel-unknown-linux-gnu"; } // platforms.gcc_mips32r2_o32; - mipsisa32r6-linux-gnu = { config = "mipsisa32r6-unknown-linux-gnu"; } // platforms.gcc_mips32r6_o32; - mipsisa32r6el-linux-gnu = { config = "mipsisa32r6el-unknown-linux-gnu"; } // platforms.gcc_mips32r6_o32; + mips-linux-gnu = { config = "mips-unknown-linux-gnu"; } // platforms.gcc_mips32r2_o32; + mipsel-linux-gnu = { config = "mipsel-unknown-linux-gnu"; } // platforms.gcc_mips32r2_o32; # require 64bit chip (for more registers, 64-bit floating point, 64-bit "long long") but use 32bit pointers - mips64-linux-gnuabin32 = { config = "mips64-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r2_n32; - mips64el-linux-gnuabin32 = { config = "mips64el-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r2_n32; - mipsisa64r6-linux-gnuabin32 = { config = "mipsisa64r6-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r6_n32; - mipsisa64r6el-linux-gnuabin32 = { config = "mipsisa64r6el-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r6_n32; + mips64-linux-gnuabin32 = { config = "mips64-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r2_n32; + mips64el-linux-gnuabin32 = { config = "mips64el-unknown-linux-gnuabin32"; } // platforms.gcc_mips64r2_n32; # 64bit pointers - mips64-linux-gnuabi64 = { config = "mips64-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r2_64; - mips64el-linux-gnuabi64 = { config = "mips64el-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r2_64; - mipsisa64r6-linux-gnuabi64 = { config = "mipsisa64r6-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r6_64; - mipsisa64r6el-linux-gnuabi64 = { config = "mipsisa64r6el-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r6_64; + mips64-linux-gnuabi64 = { config = "mips64-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r2_64; + mips64el-linux-gnuabi64 = { config = "mips64el-unknown-linux-gnuabi64"; } // platforms.gcc_mips64r2_64; muslpi = raspberryPi // { config = "armv6l-unknown-linux-musleabihf"; @@ -136,6 +129,10 @@ rec { libc = "newlib"; }; + loongarch64-linux = { + config = "loongarch64-unknown-linux-gnu"; + }; + mmix = { config = "mmix-unknown-mmixware"; libc = "newlib"; @@ -304,15 +301,18 @@ rec { # BSDs + x86_64-freebsd = { + config = "x86_64-unknown-freebsd13"; + useLLVM = true; + }; + x86_64-netbsd = { config = "x86_64-unknown-netbsd"; - libc = "nblibc"; }; # this is broken and never worked fully x86_64-netbsd-llvm = { config = "x86_64-unknown-netbsd"; - libc = "nblibc"; useLLVM = true; }; @@ -327,6 +327,9 @@ rec { # Ghcjs ghcjs = { - config = "js-unknown-ghcjs"; + # This triple is special to GHC/Cabal/GHCJS and not recognized by autotools + # See: https://gitlab.haskell.org/ghc/ghc/-/commit/6636b670233522f01d002c9b97827d00289dbf5c + # https://github.com/ghcjs/ghcjs/issues/53 + config = "javascript-unknown-ghcjs"; }; } diff --git a/nixpkgs/lib/systems/flake-systems.nix b/nixpkgs/lib/systems/flake-systems.nix index 74124c32e836..b1988c6a4fbb 100644 --- a/nixpkgs/lib/systems/flake-systems.nix +++ b/nixpkgs/lib/systems/flake-systems.nix @@ -1,6 +1,6 @@ # See [RFC 46] for mandated platform support and ../../pkgs/stdenv for # implemented platform support. This list is mainly descriptive, i.e. all -# system doubles for platforms where nixpkgs can do native compiliation +# system doubles for platforms where nixpkgs can do native compilation # reasonably well are included. # # [RFC 46]: https://github.com/NixOS/rfcs/blob/master/rfcs/0046-platform-support-tiers.md diff --git a/nixpkgs/lib/systems/inspect.nix b/nixpkgs/lib/systems/inspect.nix index dbffca0300b5..89e9f4231d97 100644 --- a/nixpkgs/lib/systems/inspect.nix +++ b/nixpkgs/lib/systems/inspect.nix @@ -7,16 +7,36 @@ let abis_ = abis; in let abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) abis_; in rec { + # these patterns are to be matched against {host,build,target}Platform.parsed patterns = rec { + # The patterns below are lists in sum-of-products form. + # + # Each attribute is list of product conditions; non-list values are treated + # as a singleton list. If *any* product condition in the list matches then + # the predicate matches. Each product condition is tested by + # `lib.attrsets.matchAttrs`, which requires a match on *all* attributes of + # the product. + isi686 = { cpu = cpuTypes.i686; }; isx86_32 = { cpu = { family = "x86"; bits = 32; }; }; isx86_64 = { cpu = { family = "x86"; bits = 64; }; }; isPower = { cpu = { family = "power"; }; }; isPower64 = { cpu = { family = "power"; bits = 64; }; }; + # This ABI is the default in NixOS PowerPC64 BE, but not on mainline GCC, + # so it sometimes causes issues in certain packages that makes the wrong + # assumption on the used ABI. + isAbiElfv2 = [ + { abi = { abi = "elfv2"; }; } + { abi = { name = "musl"; }; cpu = { family = "power"; bits = 64; }; } + ]; isx86 = { cpu = { family = "x86"; }; }; isAarch32 = { cpu = { family = "arm"; bits = 32; }; }; + isArmv7 = map ({ arch, ... }: { cpu = { inherit arch; }; }) + (lib.filter (cpu: lib.hasPrefix "armv7" cpu.arch or "") + (lib.attrValues cpuTypes)); isAarch64 = { cpu = { family = "arm"; bits = 64; }; }; isAarch = { cpu = { family = "arm"; }; }; + isMicroBlaze = { cpu = { family = "microblaze"; }; }; isMips = { cpu = { family = "mips"; }; }; isMips32 = { cpu = { family = "mips"; bits = 32; }; }; isMips64 = { cpu = { family = "mips"; bits = 64; }; }; @@ -36,10 +56,13 @@ rec { isOr1k = { cpu = { family = "or1k"; }; }; isM68k = { cpu = { family = "m68k"; }; }; isS390 = { cpu = { family = "s390"; }; }; - isJavaScript = { cpu = cpuTypes.js; }; + isS390x = { cpu = { family = "s390"; bits = 64; }; }; + isLoongArch64 = { cpu = { family = "loongarch"; bits = 64; }; }; + isJavaScript = { cpu = cpuTypes.javascript; }; is32bit = { cpu = { bits = 32; }; }; is64bit = { cpu = { bits = 64; }; }; + isILP32 = map (a: { abi = { abi = a; }; }) [ "n32" "ilp32" "x32" ]; isBigEndian = { cpu = { significantByte = significantBytes.bigEndian; }; }; isLittleEndian = { cpu = { significantByte = significantBytes.littleEndian; }; }; @@ -51,7 +74,7 @@ rec { isiOS = { kernel = kernels.ios; }; isLinux = { kernel = kernels.linux; }; isSunOS = { kernel = kernels.solaris; }; - isFreeBSD = { kernel = kernels.freebsd; }; + isFreeBSD = { kernel = { name = "freebsd"; }; }; isNetBSD = { kernel = kernels.netbsd; }; isOpenBSD = { kernel = kernels.openbsd; }; isWindows = { kernel = kernels.windows; }; @@ -64,12 +87,17 @@ rec { isNone = { kernel = kernels.none; }; isAndroid = [ { abi = abis.android; } { abi = abis.androideabi; } ]; - isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf ]; + isGnu = with abis; map (a: { abi = a; }) [ gnuabi64 gnu gnueabi gnueabihf gnuabielfv1 gnuabielfv2 ]; isMusl = with abis; map (a: { abi = a; }) [ musl musleabi musleabihf muslabin32 muslabi64 ]; isUClibc = with abis; map (a: { abi = a; }) [ uclibc uclibceabi uclibceabihf ]; - isEfi = map (family: { cpu.family = family; }) - [ "x86" "arm" "aarch64" ]; + isEfi = [ + { cpu = { family = "arm"; version = "6"; }; } + { cpu = { family = "arm"; version = "7"; }; } + { cpu = { family = "arm"; version = "8"; }; } + { cpu = { family = "riscv"; }; } + { cpu = { family = "x86"; }; } + ]; }; matchAnyAttrs = patterns: @@ -77,4 +105,13 @@ rec { else matchAttrs patterns; predicates = mapAttrs (_: matchAnyAttrs) patterns; + + # these patterns are to be matched against the entire + # {host,build,target}Platform structure; they include a `parsed={}` marker so + # that `lib.meta.availableOn` can distinguish them from the patterns which + # apply only to the `parsed` field. + + platformPatterns = mapAttrs (_: p: { parsed = {}; } // p) { + isStatic = { isStatic = true; }; + }; } diff --git a/nixpkgs/lib/systems/parse.nix b/nixpkgs/lib/systems/parse.nix index 9d2571c993a9..6eb4f27cc519 100644 --- a/nixpkgs/lib/systems/parse.nix +++ b/nixpkgs/lib/systems/parse.nix @@ -88,6 +88,9 @@ rec { i686 = { bits = 32; significantByte = littleEndian; family = "x86"; arch = "i686"; }; x86_64 = { bits = 64; significantByte = littleEndian; family = "x86"; arch = "x86-64"; }; + microblaze = { bits = 32; significantByte = bigEndian; family = "microblaze"; }; + microblazeel = { bits = 32; significantByte = littleEndian; family = "microblaze"; }; + mips = { bits = 32; significantByte = bigEndian; family = "mips"; }; mipsel = { bits = 32; significantByte = littleEndian; family = "mips"; }; mips64 = { bits = 64; significantByte = bigEndian; family = "mips"; }; @@ -124,7 +127,9 @@ rec { or1k = { bits = 32; significantByte = bigEndian; family = "or1k"; }; - js = { bits = 32; significantByte = littleEndian; family = "js"; }; + loongarch64 = { bits = 64; significantByte = littleEndian; family = "loongarch"; }; + + javascript = { bits = 32; significantByte = littleEndian; family = "javascript"; }; }; # GNU build systems assume that older NetBSD architectures are using a.out. @@ -175,23 +180,12 @@ rec { (b == armv7l && isCompatible a armv7a) (b == armv7l && isCompatible a armv7r) (b == armv7l && isCompatible a armv7m) - (b == armv7a && isCompatible a armv8a) - (b == armv7r && isCompatible a armv8a) - (b == armv7m && isCompatible a armv8a) - (b == armv7a && isCompatible a armv8r) - (b == armv7r && isCompatible a armv8r) - (b == armv7m && isCompatible a armv8r) - (b == armv7a && isCompatible a armv8m) - (b == armv7r && isCompatible a armv8m) - (b == armv7m && isCompatible a armv8m) # ARMv8 - (b == armv8r && isCompatible a armv8a) - (b == armv8m && isCompatible a armv8a) - - # XXX: not always true! Some arm64 cpus don’t support arm32 mode. (b == aarch64 && a == armv8a) (b == armv8a && isCompatible a aarch64) + (b == armv8r && isCompatible a armv8a) + (b == armv8m && isCompatible a armv8a) # PowerPC (b == powerpc && isCompatible a powerpc64) @@ -287,7 +281,11 @@ rec { # the normalized name for macOS. macos = { execFormat = macho; families = { inherit darwin; }; name = "darwin"; }; ios = { execFormat = macho; families = { inherit darwin; }; }; - freebsd = { execFormat = elf; families = { inherit bsd; }; }; + # A tricky thing about FreeBSD is that there is no stable ABI across + # versions. That means that putting in the version as part of the + # config string is paramount. + freebsd12 = { execFormat = elf; families = { inherit bsd; }; name = "freebsd"; version = 12; }; + freebsd13 = { execFormat = elf; families = { inherit bsd; }; name = "freebsd"; version = 13; }; linux = { execFormat = elf; families = { }; }; netbsd = { execFormat = elf; families = { inherit bsd; }; }; none = { execFormat = unknown; families = { }; }; @@ -350,6 +348,11 @@ rec { The "gnu" ABI is ambiguous on 32-bit ARM. Use "gnueabi" or "gnueabihf" instead. ''; } + { assertion = platform: with platform; !(isPower64 && isBigEndian); + message = '' + The "gnu" ABI is ambiguous on big-endian 64-bit PowerPC. Use "gnuabielfv2" or "gnuabielfv1" instead. + ''; + } ]; }; gnuabi64 = { abi = "64"; }; @@ -361,6 +364,9 @@ rec { gnuabin32 = { abi = "n32"; }; muslabin32 = { abi = "n32"; }; + gnuabielfv2 = { abi = "elfv2"; }; + gnuabielfv1 = { abi = "elfv1"; }; + musleabi = { float = "soft"; }; musleabihf = { float = "hard"; }; musl = {}; @@ -407,27 +413,29 @@ rec { else if (elemAt l 1) == "elf" then { cpu = elemAt l 0; vendor = "unknown"; kernel = "none"; abi = elemAt l 1; } else { cpu = elemAt l 0; kernel = elemAt l 1; }; - "3" = # Awkward hacks, beware! - if elemAt l 1 == "apple" - then { cpu = elemAt l 0; vendor = "apple"; kernel = elemAt l 2; } - else if (elemAt l 1 == "linux") || (elemAt l 2 == "gnu") - then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; } - else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; } - else if (elemAt l 2 == "wasi") - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "wasi"; } - else if (elemAt l 2 == "redox") - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "redox"; } - else if (elemAt l 2 == "mmixware") - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "mmixware"; } - else if hasPrefix "netbsd" (elemAt l 2) - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } - else if (elem (elemAt l 2) ["eabi" "eabihf" "elf"]) - then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 1; abi = elemAt l 2; } - else if (elemAt l 2 == "ghcjs") - then { cpu = elemAt l 0; vendor = "unknown"; kernel = elemAt l 2; } - else if hasPrefix "genode" (elemAt l 2) - then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } + "3" = + # cpu-kernel-environment + if elemAt l 1 == "linux" || + elem (elemAt l 2) ["eabi" "eabihf" "elf" "gnu"] + then { + cpu = elemAt l 0; + kernel = elemAt l 1; + abi = elemAt l 2; + vendor = "unknown"; + } + # cpu-vendor-os + else if elemAt l 1 == "apple" || + elem (elemAt l 2) [ "wasi" "redox" "mmixware" "ghcjs" "mingw32" ] || + hasPrefix "freebsd" (elemAt l 2) || + hasPrefix "netbsd" (elemAt l 2) || + hasPrefix "genode" (elemAt l 2) + then { + cpu = elemAt l 0; + vendor = elemAt l 1; + kernel = if elemAt l 2 == "mingw32" + then "windows" # autotools breaks on -gnu for window + else elemAt l 2; + } else throw "Target specification with 3 components is ambiguous"; "4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; }; }.${toString (length l)} @@ -464,6 +472,8 @@ rec { if lib.versionAtLeast (parsed.cpu.version or "0") "6" then abis.gnueabihf else abis.gnueabi + # Default ppc64 BE to ELFv2 + else if isPower64 parsed && isBigEndian parsed then abis.gnuabielfv2 else abis.gnu else abis.unknown; }; @@ -472,10 +482,13 @@ rec { mkSystemFromString = s: mkSystemFromSkeleton (mkSkeletonFromList (lib.splitString "-" s)); + kernelName = kernel: + kernel.name + toString (kernel.version or ""); + doubleFromSystem = { cpu, kernel, abi, ... }: /**/ if abi == abis.cygnus then "${cpu.name}-cygwin" else if kernel.families ? darwin then "${cpu.name}-darwin" - else "${cpu.name}-${kernel.name}"; + else "${cpu.name}-${kernelName kernel}"; tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let optExecFormat = @@ -483,7 +496,7 @@ rec { gnuNetBSDDefaultExecFormat cpu != kernel.execFormat) kernel.execFormat.name; optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}"; - in "${cpu.name}-${vendor.name}-${kernel.name}${optExecFormat}${optAbi}"; + in "${cpu.name}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}"; ################################################################################ diff --git a/nixpkgs/lib/systems/platforms.nix b/nixpkgs/lib/systems/platforms.nix index 41c25484cea0..d574943e47df 100644 --- a/nixpkgs/lib/systems/platforms.nix +++ b/nixpkgs/lib/systems/platforms.nix @@ -557,7 +557,7 @@ rec { else if platform.isRiscV then riscv-multiplatform - else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then fuloong2f_n32 + else if platform.parsed.cpu == lib.systems.parse.cpuTypes.mipsel then (import ./examples.nix { inherit lib; }).mipsel-linux-gnu else if platform.parsed.cpu == lib.systems.parse.cpuTypes.powerpc64le then powernv |