From d289dba125c128bf03309957fee948fba32b8852 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 6 Oct 2024 10:30:40 +0200 Subject: [PATCH] llvm: Fix ilp32e/lp64e and ilp32f/lp64f ABI selection for riscv. --- src/target.zig | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/target.zig b/src/target.zig index 95c9798f65..aeef764a8d 100644 --- a/src/target.zig +++ b/src/target.zig @@ -427,17 +427,14 @@ pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 { // Once our self-hosted linker can handle both ABIs, this hack should go away. if (target.cpu.arch == .powerpc64) return "elfv2"; - const have_float = switch (target.abi) { - .gnueabihf, .musleabihf, .eabihf => true, - else => false, - }; - switch (target.cpu.arch) { .riscv64 => { const featureSetHas = std.Target.riscv.featureSetHas; - if (featureSetHas(target.cpu.features, .d)) { + if (featureSetHas(target.cpu.features, .e)) { + return "lp64e"; + } else if (featureSetHas(target.cpu.features, .d)) { return "lp64d"; - } else if (have_float) { + } else if (featureSetHas(target.cpu.features, .f)) { return "lp64f"; } else { return "lp64"; @@ -445,12 +442,12 @@ pub fn llvmMachineAbi(target: std.Target) ?[:0]const u8 { }, .riscv32 => { const featureSetHas = std.Target.riscv.featureSetHas; - if (featureSetHas(target.cpu.features, .d)) { - return "ilp32d"; - } else if (have_float) { - return "ilp32f"; - } else if (featureSetHas(target.cpu.features, .e)) { + if (featureSetHas(target.cpu.features, .e)) { return "ilp32e"; + } else if (featureSetHas(target.cpu.features, .d)) { + return "ilp32d"; + } else if (featureSetHas(target.cpu.features, .f)) { + return "ilp32f"; } else { return "ilp32"; }