authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-11-17 20:35:04+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-11-19 01:42:45+01:00
log4b99e3718b417b3f64f17014cfdc2d755b6c5f63
treea0343e27b220a5cf958dc09847d92e02f2f496e1
parent959a3612c26ba7cbed12ec981c77c9fab953c700
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

compiler: don't use self-hosted backends on big-endian hosts

https://github.com/ziglang/zig/issues/25961

4 files changed, 12 insertions(+), 5 deletions(-)

src/target.zig+2
......@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
12const std = @import("std");
23const assert = std.debug.assert;
34
......@@ -255,6 +256,7 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C
255256/// debug mode. A given target should only return true here if it is passing greater
256257/// than or equal to the number of behavior tests as the respective LLVM backend.
257258pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
259 if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961
258260 if (target.cpu.arch.isSpirV()) return true;
259261 if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {
260262 if (target.os.tag == .illumos) {
test/src/ErrorTrace.zig+1
......@@ -39,6 +39,7 @@ pub fn addCase(self: *ErrorTrace, case: Case) void {
3939}
4040
4141fn shouldTestNonLlvm(target: *const std.Target) bool {
42 if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961
4243 return switch (target.cpu.arch) {
4344 .x86_64 => switch (target.ofmt) {
4445 .elf => !target.os.tag.isBSD() and target.os.tag != .illumos,
test/src/StackTrace.zig+8-5
......@@ -44,12 +44,15 @@ fn addCaseTarget(
4444 target: *const std.Build.ResolvedTarget,
4545 triple: ?[]const u8,
4646) void {
47 const both_backends = switch (target.result.cpu.arch) {
48 .x86_64 => switch (target.result.ofmt) {
49 .elf => !target.result.os.tag.isBSD() and target.result.os.tag != .illumos,
47 const both_backends = b: {
48 if (comptime builtin.cpu.arch.endian() == .big) break :b false; // https://github.com/ziglang/zig/issues/25961
49 break :b switch (target.result.cpu.arch) {
50 .x86_64 => switch (target.result.ofmt) {
51 .elf => !target.result.os.tag.isBSD() and target.result.os.tag != .illumos,
52 else => false,
53 },
5054 else => false,
51 },
52 else => false,
55 };
5356 };
5457 const both_pie = switch (target.result.os.tag) {
5558 .fuchsia, .openbsd => false,
test/tests.zig+1
......@@ -2500,6 +2500,7 @@ fn addOneModuleTest(
25002500}
25012501
25022502pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {
2503 if (comptime builtin.cpu.arch.endian() == .big) return true; // https://github.com/ziglang/zig/issues/25961
25032504 if (use_llvm) |x| return x;
25042505 if (query.ofmt == .c) return false;
25052506 switch (optimize_mode) {