From c1a70acc916b7278a3f7702d6712b20ecbbb62a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 00:53:24 +0200 Subject: [PATCH 01/15] std.zig.target: Split `mips(el)-linux-musl` triples into `mips(el)-linux-musleabi(hf)`. Closes #21184. --- lib/std/zig/target.zig | 6 ++++-- test/tests.zig | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index d0d68acd70fd..f28904a65c1f 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -46,10 +46,12 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .mips64, .os = .linux, .abi = .musl }, .{ .arch = .mipsel, .os = .linux, .abi = .gnueabi }, .{ .arch = .mipsel, .os = .linux, .abi = .gnueabihf }, - .{ .arch = .mipsel, .os = .linux, .abi = .musl }, + .{ .arch = .mipsel, .os = .linux, .abi = .musleabi }, + .{ .arch = .mipsel, .os = .linux, .abi = .musleabihf }, .{ .arch = .mips, .os = .linux, .abi = .gnueabi }, .{ .arch = .mips, .os = .linux, .abi = .gnueabihf }, - .{ .arch = .mips, .os = .linux, .abi = .musl }, + .{ .arch = .mips, .os = .linux, .abi = .musleabi }, + .{ .arch = .mips, .os = .linux, .abi = .musleabihf }, .{ .arch = .powerpc64le, .os = .linux, .abi = .gnu, .glibc_min = .{ .major = 2, .minor = 19, .patch = 0 } }, .{ .arch = .powerpc64le, .os = .linux, .abi = .musl }, .{ .arch = .powerpc64, .os = .linux, .abi = .gnu }, diff --git a/test/tests.zig b/test/tests.zig index 7d5be7bbf74c..6733c52de614 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -323,7 +323,7 @@ const test_targets = blk: { .target = .{ .cpu_arch = .mips, .os_tag = .linux, - .abi = .musl, + .abi = .musleabihf, }, .link_libc = true, .slow_backend = true, @@ -350,7 +350,7 @@ const test_targets = blk: { .target = .{ .cpu_arch = .mipsel, .os_tag = .linux, - .abi = .musl, + .abi = .musleabihf, }, .link_libc = true, .slow_backend = true, @@ -661,7 +661,7 @@ const c_abi_targets = [_]CAbiTarget{ .target = .{ .cpu_arch = .mips, .os_tag = .linux, - .abi = .musl, + .abi = .musleabihf, }, }, .{ From 17f54e827499058e281abeab5d6634bf415c3580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 00:54:06 +0200 Subject: [PATCH 02/15] std.zig.target: Split `powerpc-linux-musl` triple into `powerpc-linux-musleabi(hf)`. --- lib/std/zig/target.zig | 3 ++- test/tests.zig | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/std/zig/target.zig b/lib/std/zig/target.zig index f28904a65c1f..b60586da8519 100644 --- a/lib/std/zig/target.zig +++ b/lib/std/zig/target.zig @@ -58,7 +58,8 @@ pub const available_libcs = [_]ArchOsAbi{ .{ .arch = .powerpc64, .os = .linux, .abi = .musl }, .{ .arch = .powerpc, .os = .linux, .abi = .gnueabi }, .{ .arch = .powerpc, .os = .linux, .abi = .gnueabihf }, - .{ .arch = .powerpc, .os = .linux, .abi = .musl }, + .{ .arch = .powerpc, .os = .linux, .abi = .musleabi }, + .{ .arch = .powerpc, .os = .linux, .abi = .musleabihf }, .{ .arch = .riscv32, .os = .linux, .abi = .gnu, .glibc_min = .{ .major = 2, .minor = 33, .patch = 0 } }, .{ .arch = .riscv32, .os = .linux, .abi = .musl }, .{ .arch = .riscv64, .os = .linux, .abi = .gnu, .glibc_min = .{ .major = 2, .minor = 27, .patch = 0 } }, diff --git a/test/tests.zig b/test/tests.zig index 6733c52de614..b87113c12dc2 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -424,7 +424,7 @@ const test_targets = blk: { .target = .{ .cpu_arch = .powerpc, .os_tag = .linux, - .abi = .musl, + .abi = .musleabihf, }, .link_libc = true, }, @@ -682,7 +682,7 @@ const c_abi_targets = [_]CAbiTarget{ .target = .{ .cpu_arch = .powerpc, .os_tag = .linux, - .abi = .musl, + .abi = .musleabihf, }, }, .{ From af370a69cd16305e2cd14b584187e84e30bd065f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 00:44:35 +0200 Subject: [PATCH 03/15] std.Target: Make Abi.floatAbi() more accurate. Also rename Target.getFloatAbi() to floatAbi(). --- lib/std/Target.zig | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/std/Target.zig b/lib/std/Target.zig index d215e29fc88e..60f75e25fad0 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -765,12 +765,13 @@ pub const Abi = enum { pub inline fn floatAbi(abi: Abi) FloatAbi { return switch (abi) { - .gnueabihf, - .eabihf, - .musleabihf, - => .hard, - .ohos => .soft, - else => .soft, + .eabi, + .gnueabi, + .musleabi, + .gnusf, + .ohos, + => .soft, + else => .hard, }; } }; @@ -1645,7 +1646,7 @@ pub const FloatAbi = enum { soft, }; -pub inline fn getFloatAbi(target: Target) FloatAbi { +pub inline fn floatAbi(target: Target) FloatAbi { return target.abi.floatAbi(); } From 92517fbd625b1f6d6162ce2875ef167701b99733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 00:45:38 +0200 Subject: [PATCH 04/15] llvm: Set float ABI based on std.Target.floatAbi(). --- src/codegen/llvm.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index a46d875b342b..59df12df610d 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1284,8 +1284,7 @@ pub const Object = struct { .large => .Large, }; - // TODO handle float ABI better- it should depend on the ABI portion of std.Target - const float_abi: llvm.ABIType = .Default; + const float_abi: llvm.ABIType = if (comp.root_mod.resolved_target.result.floatAbi() == .hard) .Hard else .Soft; var target_machine = llvm.TargetMachine.create( target, From 68367999351663421939d17c87af8269c824c1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 06:56:41 +0200 Subject: [PATCH 05/15] llvm: Set use-soft-float and noimplicitfloat on functions for soft float. Closes #10961. --- src/codegen/llvm.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 59df12df610d..d7d1be6a5074 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3108,6 +3108,30 @@ pub const Object = struct { .value = .empty, } }, &o.builder); } + if (target.floatAbi() == .soft) { + // `use-soft-float` means "use software routines for floating point computations". In + // other words, it configures how LLVM lowers basic float instructions like `fcmp`, + // `fadd`, etc. The float calling convention is configured on `TargetMachine` and is + // mostly an orthogonal concept, although obviously we do need hardware float operations + // to actually be able to pass float values in float registers. + // + // Ideally, we would support something akin to the `-mfloat-abi=softfp` option that GCC + // and Clang support for Arm32 and CSKY. We don't currently expose such an option in + // Zig, and using CPU features as the source of truth for this makes for a miserable + // user experience since people expect e.g. `arm-linux-gnueabi` to mean full soft float + // unless the compiler has explicitly been told otherwise. (And note that our baseline + // CPU models almost all include FPU features!) + // + // Revisit this at some point. + try attributes.addFnAttr(.{ .string = .{ + .kind = try o.builder.string("use-soft-float"), + .value = try o.builder.string("true"), + } }, &o.builder); + + // This prevents LLVM from using FPU/SIMD code for things like `memcpy`. As for the + // above, this should be revisited if `softfp` support is added. + try attributes.addFnAttr(.noimplicitfloat, &o.builder); + } } fn resolveGlobalUav( From 70c92331c79018f8c5cc845f1015af7fa941f3a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 21:32:06 +0200 Subject: [PATCH 06/15] llvm: Limit f16/f128 lowering on arm to fp_armv8 and soft float. --- src/codegen/llvm.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index d7d1be6a5074..5ba80e3c4e34 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -12423,6 +12423,11 @@ fn backendSupportsF16(target: std.Target) bool { .mips64el, .s390x, => false, + .arm, + .armeb, + .thumb, + .thumbeb, + => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), .aarch64, .aarch64_be, => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8), @@ -12445,6 +12450,11 @@ fn backendSupportsF128(target: std.Target) bool { .powerpc64, .powerpc64le, => target.os.tag != .aix, + .arm, + .armeb, + .thumb, + .thumbeb, + => target.floatAbi() == .soft or std.Target.arm.featureSetHas(target.cpu.features, .fp_armv8), .aarch64, .aarch64_be, => std.Target.aarch64.featureSetHas(target.cpu.features, .fp_armv8), From 77c8f4b6713c5209f0cde62001b5995641f8bf60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 07:18:29 +0200 Subject: [PATCH 07/15] Compilation: Pass hard/soft float flags to Clang as appropriate. --- src/Compilation.zig | 22 ++++++++++++++++++---- src/target.zig | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/src/Compilation.zig b/src/Compilation.zig index 54fa1208569f..ffd004b93e2a 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -5484,6 +5484,9 @@ pub fn addCCArgs( const is_enabled = target.cpu.features.isEnabled(index); if (feature.llvm_name) |llvm_name| { + // We communicate float ABI to Clang through the dedicated options further down. + if (std.mem.eql(u8, llvm_name, "soft-float")) continue; + argv.appendSliceAssumeCapacity(&[_][]const u8{ "-Xclang", "-target-feature", "-Xclang" }); const plus_or_minus = "-+"[@intFromBool(is_enabled)]; const arg = try std.fmt.allocPrint(arena, "{c}{s}", .{ plus_or_minus, llvm_name }); @@ -5705,10 +5708,6 @@ pub fn addCCArgs( if (target.cpu.model.llvm_name) |llvm_name| { try argv.append(try std.fmt.allocPrint(arena, "-march={s}", .{llvm_name})); } - - if (std.Target.mips.featureSetHas(target.cpu.features, .soft_float)) { - try argv.append("-msoft-float"); - } }, else => { // TODO @@ -5751,6 +5750,21 @@ pub fn addCCArgs( try argv.append(try std.fmt.allocPrint(arena, "-mabi={s}", .{mabi})); } + // We might want to support -mfloat-abi=softfp for Arm and CSKY here in the future. + if (target_util.clangSupportsFloatAbiArg(target)) { + const fabi = @tagName(target.floatAbi()); + + try argv.append(switch (target.cpu.arch) { + // For whatever reason, Clang doesn't support `-mfloat-abi` for s390x. + .s390x => try std.fmt.allocPrint(arena, "-m{s}-float", .{fabi}), + else => try std.fmt.allocPrint(arena, "-mfloat-abi={s}", .{fabi}), + }); + } + + if (target_util.clangSupportsNoImplicitFloatArg(target) and target.floatAbi() == .soft) { + try argv.append("-mno-implicit-float"); + } + if (out_dep_path) |p| { try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", p }); } diff --git a/src/target.zig b/src/target.zig index 221c2029baf9..59c151bd6e64 100644 --- a/src/target.zig +++ b/src/target.zig @@ -339,6 +339,48 @@ pub fn clangAssemblerSupportsMcpuArg(target: std.Target) bool { }; } +pub fn clangSupportsFloatAbiArg(target: std.Target) bool { + return switch (target.cpu.arch) { + .arm, + .armeb, + .thumb, + .thumbeb, + .csky, + .mips, + .mipsel, + .mips64, + .mips64el, + .powerpc, + .powerpcle, + .powerpc64, + .powerpc64le, + .s390x, + .sparc, + .sparc64, + => true, + // We use the target triple for LoongArch. + .loongarch32, .loongarch64 => false, + else => false, + }; +} + +pub fn clangSupportsNoImplicitFloatArg(target: std.Target) bool { + return switch (target.cpu.arch) { + .aarch64, + .aarch64_be, + .arm, + .armeb, + .thumb, + .thumbeb, + .riscv32, + .riscv64, + .x86, + .x86_64, + => true, + else => false, + }; +} + pub fn needUnwindTables(target: std.Target) bool { return target.os.tag == .windows or target.isDarwin() or std.debug.Dwarf.abi.supportsUnwinding(target); } From f9455511faba40ad719fa0e6897ea09ac5fb9d23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 25 Aug 2024 06:57:18 +0200 Subject: [PATCH 08/15] Compilation: Work around llvm/llvm-project#105972 by defining the macros. https://github.com/llvm/llvm-project/issues/105972 --- src/Compilation.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Compilation.zig b/src/Compilation.zig index ffd004b93e2a..bd93b2061b48 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -5765,6 +5765,13 @@ pub fn addCCArgs( try argv.append("-mno-implicit-float"); } + // https://github.com/llvm/llvm-project/issues/105972 + if (target.cpu.arch.isPowerPC() and target.floatAbi() == .soft) { + try argv.append("-D__NO_FPRS__"); + try argv.append("-D_SOFT_FLOAT"); + try argv.append("-D_SOFT_DOUBLE"); + } + if (out_dep_path) |p| { try argv.appendSlice(&[_][]const u8{ "-MD", "-MV", "-MF", p }); } From 65d36be4a80c45897b344e10cc7e63daafcab9fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Tue, 27 Aug 2024 02:46:54 +0200 Subject: [PATCH 09/15] std.zig.system: Work around llvm/llvm-project#105978 by disabling vfp2. https://github.com/llvm/llvm-project/issues/105978 --- lib/std/zig/system.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 4de1e2065671..046bd3854e45 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -384,6 +384,12 @@ pub fn resolveTargetQuery(query: Target.Query) DetectError!Target { query.cpu_features_add, query.cpu_features_sub, ); + + // https://github.com/llvm/llvm-project/issues/105978 + if (result.cpu.arch.isArmOrThumb() and result.floatAbi() == .soft) { + result.cpu.features.removeFeature(@intFromEnum(Target.arm.Feature.vfp2)); + } + return result; } From 4fcd3e00fad48b15c19f6ed4771fc73adae30f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 17:37:23 +0200 Subject: [PATCH 10/15] musl: Build with -ffp-contract=off. https://www.openwall.com/lists/musl/2024/08/28/1 --- src/musl.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/src/musl.zig b/src/musl.zig index acf590203349..5ddbcb66522c 100644 --- a/src/musl.zig +++ b/src/musl.zig @@ -387,6 +387,7 @@ fn addCcArgs( "-fno-builtin", "-fexcess-precision=standard", "-frounding-math", + "-ffp-contract=off", "-fno-strict-aliasing", "-Wa,--noexecstack", "-D_XOPEN_SOURCE=700", From 5285f41267f20150d58a40a96e4380a3b611955d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 10:00:04 +0200 Subject: [PATCH 11/15] test: Disable `store vector with memset` on soft float arm. https://github.com/ziglang/zig/issues/16177 --- test/behavior/vector.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/behavior/vector.zig b/test/behavior/vector.zig index cee9f168f193..9baba8485085 100644 --- a/test/behavior/vector.zig +++ b/test/behavior/vector.zig @@ -1442,7 +1442,14 @@ test "store vector with memset" { if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_llvm) { + // LLVM 16 ERROR: "Converting bits to bytes lost precision" + // https://github.com/ziglang/zig/issues/16177 switch (builtin.target.cpu.arch) { + .arm, + .armeb, + .thumb, + .thumbeb, + => if (builtin.target.floatAbi() == .soft) return error.SkipZigTest, .wasm32, .mips, .mipsel, @@ -1451,11 +1458,7 @@ test "store vector with memset" { .riscv64, .powerpc, .powerpc64, - => { - // LLVM 16 ERROR: "Converting bits to bytes lost precision" - // https://github.com/ziglang/zig/issues/16177 - return error.SkipZigTest; - }, + => return error.SkipZigTest, else => {}, } } From 26119bd98d2f867eb06eeea9431883931d806dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 21:04:45 +0200 Subject: [PATCH 12/15] test: Skip some floating point tests that fail on `arm-linux-(gnu,musl)eabi`. https://github.com/ziglang/zig/issues/21234 --- lib/std/math/gamma.zig | 3 +++ test/behavior/floatop.zig | 2 ++ test/behavior/math.zig | 1 + 3 files changed, 6 insertions(+) diff --git a/lib/std/math/gamma.zig b/lib/std/math/gamma.zig index ce37db496215..5ac041e195df 100644 --- a/lib/std/math/gamma.zig +++ b/lib/std/math/gamma.zig @@ -3,6 +3,7 @@ // // https://git.musl-libc.org/cgit/musl/tree/src/math/tgamma.c +const builtin = @import("builtin"); const std = @import("../std.zig"); /// Returns the gamma function of x, @@ -262,6 +263,8 @@ test gamma { } test "gamma.special" { + if (builtin.cpu.arch.isArmOrThumb() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 + inline for (&.{ f32, f64 }) |T| { try expect(std.math.isNan(gamma(T, -std.math.nan(T)))); try expect(std.math.isNan(gamma(T, std.math.nan(T)))); diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index f9f2579b0aca..d799c9133119 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -126,6 +126,7 @@ test "cmp f16" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; + if (builtin.cpu.arch.isArmOrThumb() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 try testCmp(f16); try comptime testCmp(f16); @@ -134,6 +135,7 @@ test "cmp f16" { test "cmp f32/f64" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; + if (builtin.cpu.arch.isArmOrThumb() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 try testCmp(f32); try comptime testCmp(f32); diff --git a/test/behavior/math.zig b/test/behavior/math.zig index 7837ffb74b4b..c658ea3081df 100644 --- a/test/behavior/math.zig +++ b/test/behavior/math.zig @@ -1597,6 +1597,7 @@ test "NaN comparison" { if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; + if (builtin.cpu.arch.isArmOrThumb() and builtin.target.floatAbi() == .soft) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/21234 try testNanEqNan(f16); try testNanEqNan(f32); From a872b6102167f8588704877f8143d58f3386b78c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 21:31:40 +0200 Subject: [PATCH 13/15] test: Add arm, mips, and powerpc soft float targets to module tests. Prefer `eabi` and `eabihf` over the ambiguous `none` when not using libc. --- test/tests.zig | 95 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 4 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index b87113c12dc2..cf5fd93df817 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -292,10 +292,23 @@ const test_targets = blk: { .{ .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-none", + .arch_os_abi = "arm-linux-eabi", .cpu_features = "generic+v8a", }) catch unreachable, }, + .{ + .target = std.Target.Query.parse(.{ + .arch_os_abi = "arm-linux-eabihf", + .cpu_features = "generic+v8a", + }) catch unreachable, + }, + .{ + .target = std.Target.Query.parse(.{ + .arch_os_abi = "arm-linux-musleabi", + .cpu_features = "generic+v8a", + }) catch unreachable, + .link_libc = true, + }, .{ .target = std.Target.Query.parse(.{ .arch_os_abi = "arm-linux-musleabihf", @@ -303,6 +316,13 @@ const test_targets = blk: { }) catch unreachable, .link_libc = true, }, + .{ + .target = std.Target.Query.parse(.{ + .arch_os_abi = "arm-linux-gnueabi", + .cpu_features = "generic+v8a", + }) catch unreachable, + .link_libc = true, + }, .{ .target = std.Target.Query.parse(.{ .arch_os_abi = "arm-linux-gnueabihf", @@ -315,8 +335,25 @@ const test_targets = blk: { .target = .{ .cpu_arch = .mips, .os_tag = .linux, - .abi = .none, + .abi = .eabi, + }, + .slow_backend = true, + }, + .{ + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .eabihf, + }, + .slow_backend = true, + }, + .{ + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .musleabi, }, + .link_libc = true, .slow_backend = true, }, .{ @@ -328,6 +365,15 @@ const test_targets = blk: { .link_libc = true, .slow_backend = true, }, + .{ + .target = .{ + .cpu_arch = .mips, + .os_tag = .linux, + .abi = .gnueabi, + }, + .link_libc = true, + .slow_backend = true, + }, .{ .target = .{ .cpu_arch = .mips, @@ -342,8 +388,25 @@ const test_targets = blk: { .target = .{ .cpu_arch = .mipsel, .os_tag = .linux, - .abi = .none, + .abi = .eabi, + }, + .slow_backend = true, + }, + .{ + .target = .{ + .cpu_arch = .mipsel, + .os_tag = .linux, + .abi = .eabihf, + }, + .slow_backend = true, + }, + .{ + .target = .{ + .cpu_arch = .mipsel, + .os_tag = .linux, + .abi = .musleabi, }, + .link_libc = true, .slow_backend = true, }, .{ @@ -355,6 +418,15 @@ const test_targets = blk: { .link_libc = true, .slow_backend = true, }, + .{ + .target = .{ + .cpu_arch = .mipsel, + .os_tag = .linux, + .abi = .gnueabi, + }, + .link_libc = true, + .slow_backend = true, + }, .{ .target = .{ .cpu_arch = .mipsel, @@ -417,9 +489,24 @@ const test_targets = blk: { .target = .{ .cpu_arch = .powerpc, .os_tag = .linux, - .abi = .none, + .abi = .eabi, }, }, + .{ + .target = .{ + .cpu_arch = .powerpc, + .os_tag = .linux, + .abi = .eabihf, + }, + }, + .{ + .target = .{ + .cpu_arch = .powerpc, + .os_tag = .linux, + .abi = .musleabi, + }, + .link_libc = true, + }, .{ .target = .{ .cpu_arch = .powerpc, From 75983c692fad81120a7c641a54c2eb90bc467def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Wed, 28 Aug 2024 21:42:34 +0200 Subject: [PATCH 14/15] test: Switch all `arm-linux-*` triples for module tests from v8a to v7a. Broadly speaking, versions 6, 7, and 8 are the ones that are in common use. Of these, v7 is what you'll typically see for 32-bit Arm today. So let's actually make sure that that's what we're testing. --- test/tests.zig | 54 ++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/test/tests.zig b/test/tests.zig index cf5fd93df817..f07f67c2e1c6 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -291,43 +291,49 @@ const test_targets = blk: { }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-eabi", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .eabi, + }, }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-eabihf", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .eabihf, + }, }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-musleabi", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .musleabi, + }, .link_libc = true, }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-musleabihf", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .musleabihf, + }, .link_libc = true, }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-gnueabi", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .gnueabi, + }, .link_libc = true, }, .{ - .target = std.Target.Query.parse(.{ - .arch_os_abi = "arm-linux-gnueabihf", - .cpu_features = "generic+v8a", - }) catch unreachable, + .target = .{ + .cpu_arch = .arm, + .os_tag = .linux, + .abi = .gnueabihf, + }, .link_libc = true, }, From f1645772c1881a233ffcfc5072710040c4881deb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 1 Sep 2024 10:40:23 +0200 Subject: [PATCH 15/15] compiler_rt: Export __truncdfhf2() for AEABI too. Similar to __truncsfhf2() and __extendhfsf2(). --- lib/compiler_rt/truncdfhf2.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/compiler_rt/truncdfhf2.zig b/lib/compiler_rt/truncdfhf2.zig index e15a2202a165..10f13d504788 100644 --- a/lib/compiler_rt/truncdfhf2.zig +++ b/lib/compiler_rt/truncdfhf2.zig @@ -6,9 +6,8 @@ pub const panic = common.panic; comptime { if (common.want_aeabi) { @export(&__aeabi_d2h, .{ .name = "__aeabi_d2h", .linkage = common.linkage, .visibility = common.visibility }); - } else { - @export(&__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility }); } + @export(&__truncdfhf2, .{ .name = "__truncdfhf2", .linkage = common.linkage, .visibility = common.visibility }); } pub fn __truncdfhf2(a: f64) callconv(.C) common.F16T(f64) {