From 4d6a0bb9667c8083076a96744bdc71643c6febc6 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 1 Jun 2021 14:54:14 +0000 Subject: [PATCH] lib.systems.parsed: add "elf" for some NetBSD archs In Autoconf, some old NetBSD targets like "i686-unknown-netbsd" are interpreted as a.out, not elf, and virtually nothing supports it. We need to specify e.g. "i686-unknown-netbsdelf" to get the right behaviour. --- lib/systems/parse.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index b27d37f55ae..2b789fd8ecb 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -121,6 +121,14 @@ rec { js = { bits = 32; significantByte = littleEndian; family = "js"; }; }; + # GNU build systems assume that older NetBSD architectures are using a.out. + gnuNetBSDDefaultExecFormat = cpu: + if (cpu.family == "x86" && cpu.bits == 32) || + (cpu.family == "arm" && cpu.bits == 32) || + (cpu.family == "sparc" && cpu.bits == 32) + then execFormats.aout + else execFormats.elf; + # Determine when two CPUs are compatible with each other. That is, # can code built for system B run on system A? For that to happen, # the programs that system B accepts must be a subset of the @@ -463,8 +471,12 @@ rec { else "${cpu.name}-${kernel.name}"; tripleFromSystem = { cpu, vendor, kernel, abi, ... } @ sys: assert isSystem sys; let + optExecFormat = + lib.optionalString (kernel.name == "netbsd" && + gnuNetBSDDefaultExecFormat cpu != kernel.execFormat) + kernel.execFormat.name; optAbi = lib.optionalString (abi != abis.unknown) "-${abi.name}"; - in "${cpu.name}-${vendor.name}-${kernel.name}${optAbi}"; + in "${cpu.name}-${vendor.name}-${kernel.name}${optExecFormat}${optAbi}"; ################################################################################