From a22797d356f5c47428a9b7c74ee9334a24101fa8 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 24 Jul 2018 21:02:46 -0400 Subject: systems: fix netbsd triple parsing binutils expects x86_64-unknown-netbsd (only 3 parts!). Any other combo seems to fail. Also handle darwin versions similarly. /cc @Ericson2314 --- lib/systems/parse.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/systems') diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 47841a9eba5c..b07396a9dfd7 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -18,6 +18,7 @@ with lib.lists; with lib.types; with lib.attrsets; +with lib.strings; with (import ./inspect.nix { inherit lib; }).predicates; let @@ -179,9 +180,6 @@ rec { } // { # aliases # 'darwin' is the kernel for all of them. We choose macOS by default. darwin = kernels.macos; - # TODO(@Ericson2314): Handle these Darwin version suffixes more generally. - darwin10 = kernels.macos; - darwin14 = kernels.macos; watchos = kernels.ios; tvos = kernels.ios; win32 = kernels.windows; @@ -269,6 +267,8 @@ rec { 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"; abi = "gnu"; } + else if hasPrefix "netbsd" (elemAt l 2) + then { cpu = elemAt l 0; vendor = elemAt l 1; kernel = 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)} @@ -295,7 +295,9 @@ rec { else if isDarwin parsed then vendors.apple else if isWindows parsed then vendors.pc else vendors.unknown; - kernel = getKernel args.kernel; + kernel = if hasPrefix "darwin" args.kernel then getKernel "darwin" + else if hasPrefix "netbsd" args.kernel then getKernel "netbsd" + else getKernel args.kernel; abi = /**/ if args ? abi then getAbi args.abi else if isLinux parsed then -- cgit 1.4.1