zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 4b99e3718b417b3f64f17014cfdc2d755b6c5f63 (tree)
parent 959a3612c26ba7cbed12ec981c77c9fab953c700
Author: Alex Rønne Petersen <alex@alexrp.com>
Date:   Mon, 17 Nov 2025 20:35:04 +0100

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

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

Diffstat:
Msrc/target.zig | 2++
Mtest/src/ErrorTrace.zig | 1+
Mtest/src/StackTrace.zig | 13++++++++-----
Mtest/tests.zig | 1+
4 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/src/target.zig b/src/target.zig @@ -1,3 +1,4 @@ +const builtin = @import("builtin"); const std = @import("std"); const assert = std.debug.assert; @@ -255,6 +256,7 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C /// debug mode. A given target should only return true here if it is passing greater /// than or equal to the number of behavior tests as the respective LLVM backend. pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool { + if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961 if (target.cpu.arch.isSpirV()) return true; if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) { if (target.os.tag == .illumos) { diff --git a/test/src/ErrorTrace.zig b/test/src/ErrorTrace.zig @@ -39,6 +39,7 @@ pub fn addCase(self: *ErrorTrace, case: Case) void { } fn shouldTestNonLlvm(target: *const std.Target) bool { + if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961 return switch (target.cpu.arch) { .x86_64 => switch (target.ofmt) { .elf => !target.os.tag.isBSD() and target.os.tag != .illumos, diff --git a/test/src/StackTrace.zig b/test/src/StackTrace.zig @@ -44,12 +44,15 @@ fn addCaseTarget( target: *const std.Build.ResolvedTarget, triple: ?[]const u8, ) void { - const both_backends = switch (target.result.cpu.arch) { - .x86_64 => switch (target.result.ofmt) { - .elf => !target.result.os.tag.isBSD() and target.result.os.tag != .illumos, + const both_backends = b: { + if (comptime builtin.cpu.arch.endian() == .big) break :b false; // https://github.com/ziglang/zig/issues/25961 + break :b switch (target.result.cpu.arch) { + .x86_64 => switch (target.result.ofmt) { + .elf => !target.result.os.tag.isBSD() and target.result.os.tag != .illumos, + else => false, + }, else => false, - }, - else => false, + }; }; const both_pie = switch (target.result.os.tag) { .fuchsia, .openbsd => false, diff --git a/test/tests.zig b/test/tests.zig @@ -2500,6 +2500,7 @@ fn addOneModuleTest( } pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool { + if (comptime builtin.cpu.arch.endian() == .big) return true; // https://github.com/ziglang/zig/issues/25961 if (use_llvm) |x| return x; if (query.ofmt == .c) return false; switch (optimize_mode) {