From 2dac25915092da67eb218da820684d625c927e5b Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Fri, 5 May 2023 17:58:09 +0000 Subject: [PATCH] lib.systems: accept *-unknown-elf triples These are the canonical GNU triples for various embedded targets. Previously, we only accepted the LLVM-style *-none-elf, which was problematic, because a Matrix user reported needing riscv64-unknown-elf-gcc for some software, and it makes sense for us to be able to produce that. Nixpkgs used to accept such triples, but it was broken by 3b32c920d56. With this change, both forms are accepted, and parse equally. Tested that riscv64-unknown-elf is now parsed correctly, and all examples still evaluate. Link: https://github.com/NixOS/nixpkgs/issues/165836 Fixes: 3b32c920d56 ("systems/parse.nix: support eabihf") --- lib/systems/parse.nix | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index ea8e1ff8fcf07..b7560275d7a0f 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -419,8 +419,7 @@ rec { else { cpu = elemAt l 0; kernel = elemAt l 1; }; "3" = # cpu-kernel-environment - if elemAt l 1 == "linux" || - elem (elemAt l 2) ["eabi" "eabihf" "elf" "gnu"] + if elemAt l 1 == "linux" then { cpu = elemAt l 0; kernel = elemAt l 1; @@ -429,16 +428,20 @@ rec { } # cpu-vendor-os else if elemAt l 1 == "apple" || - elem (elemAt l 2) [ "wasi" "redox" "mmixware" "ghcjs" "mingw32" ] || + elem (elemAt l 2) [ "elf" "ghcjs" "gnu" "mingw32" "mmixware" "redox" "wasi" ] || + hasPrefix "eabi" (elemAt l 2) || hasPrefix "freebsd" (elemAt l 2) || hasPrefix "netbsd" (elemAt l 2) || hasPrefix "genode" (elemAt l 2) then { + kernel = "none"; + } // { 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; + vendor = if elemAt l 1 == "none" then "unknown" else elemAt l 1; + ${if hasPrefix "eabi" (elemAt l 2) || elem (elemAt l 2) [ "elf" "gnu" ] then "abi" else "kernel"} = + if elemAt l 2 == "mingw32" + then "windows" # autotools breaks on -gnu for windows + 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; };