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.
This commit is contained in:
Alyssa Ross 2021-06-01 14:54:14 +00:00
parent 5a8372d04e
commit 4d6a0bb966
1 changed files with 13 additions and 1 deletions

View File

@ -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}";
################################################################################