systems: fix netbsd triple parsing

binutils expects x86_64-unknown-netbsd<version> (only 3 parts!). Any other combo seems to fail.

Also handle darwin versions similarly.

/cc @Ericson2314

authored by

Matthew Bauer and committed by
Matthew Bauer
a22797d3 96ce1e03

+6 -4
+6 -4
lib/systems/parse.nix
··· 18 with lib.lists; 19 with lib.types; 20 with lib.attrsets; 21 with (import ./inspect.nix { inherit lib; }).predicates; 22 23 let ··· 179 } // { # aliases 180 # 'darwin' is the kernel for all of them. We choose macOS by default. 181 darwin = kernels.macos; 182 - # TODO(@Ericson2314): Handle these Darwin version suffixes more generally. 183 - darwin10 = kernels.macos; 184 - darwin14 = kernels.macos; 185 watchos = kernels.ios; 186 tvos = kernels.ios; 187 win32 = kernels.windows; ··· 269 then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; } 270 else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window 271 then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; } 272 else throw "Target specification with 3 components is ambiguous"; 273 "4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; }; 274 }.${toString (length l)} ··· 295 else if isDarwin parsed then vendors.apple 296 else if isWindows parsed then vendors.pc 297 else vendors.unknown; 298 - kernel = getKernel args.kernel; 299 abi = 300 /**/ if args ? abi then getAbi args.abi 301 else if isLinux parsed then
··· 18 with lib.lists; 19 with lib.types; 20 with lib.attrsets; 21 + with lib.strings; 22 with (import ./inspect.nix { inherit lib; }).predicates; 23 24 let ··· 180 } // { # aliases 181 # 'darwin' is the kernel for all of them. We choose macOS by default. 182 darwin = kernels.macos; 183 watchos = kernels.ios; 184 tvos = kernels.ios; 185 win32 = kernels.windows; ··· 267 then { cpu = elemAt l 0; kernel = elemAt l 1; abi = elemAt l 2; } 268 else if (elemAt l 2 == "mingw32") # autotools breaks on -gnu for window 269 then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = "windows"; abi = "gnu"; } 270 + else if hasPrefix "netbsd" (elemAt l 2) 271 + then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; } 272 else throw "Target specification with 3 components is ambiguous"; 273 "4" = { cpu = elemAt l 0; vendor = elemAt l 1; kernel = elemAt l 2; abi = elemAt l 3; }; 274 }.${toString (length l)} ··· 295 else if isDarwin parsed then vendors.apple 296 else if isWindows parsed then vendors.pc 297 else vendors.unknown; 298 + kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin" 299 + else if hasPrefix "netbsd" args.kernel then getKernel "netbsd" 300 + else getKernel args.kernel; 301 abi = 302 /**/ if args ? abi then getAbi args.abi 303 else if isLinux parsed then