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 @@...@@ -1,3 +1,4 @@
1const builtin = @import("builtin");
1const std = @import("std");2const std = @import("std");
2const assert = std.debug.assert;3const assert = std.debug.assert;
34
...@@ -255,6 +256,7 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C...@@ -255,6 +256,7 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C
255/// debug mode. A given target should only return true here if it is passing greater256/// debug mode. A given target should only return true here if it is passing greater
256/// than or equal to the number of behavior tests as the respective LLVM backend.257/// than or equal to the number of behavior tests as the respective LLVM backend.
257pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {258pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
259 if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961
258 if (target.cpu.arch.isSpirV()) return true;260 if (target.cpu.arch.isSpirV()) return true;
259 if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {261 if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {
260 if (target.os.tag == .illumos) {262 if (target.os.tag == .illumos) {
test/src/ErrorTrace.zig+1
...@@ -39,6 +39,7 @@ pub fn addCase(self: *ErrorTrace, case: Case) void {...@@ -39,6 +39,7 @@ pub fn addCase(self: *ErrorTrace, case: Case) void {
39}39}
4040
41fn shouldTestNonLlvm(target: *const std.Target) bool {41fn shouldTestNonLlvm(target: *const std.Target) bool {
42 if (comptime builtin.cpu.arch.endian() == .big) return false; // https://github.com/ziglang/zig/issues/25961
42 return switch (target.cpu.arch) {43 return switch (target.cpu.arch) {
43 .x86_64 => switch (target.ofmt) {44 .x86_64 => switch (target.ofmt) {
44 .elf => !target.os.tag.isBSD() and target.os.tag != .illumos,45 .elf => !target.os.tag.isBSD() and target.os.tag != .illumos,
test/src/StackTrace.zig+8-5
...@@ -44,12 +44,15 @@ fn addCaseTarget(...@@ -44,12 +44,15 @@ fn addCaseTarget(
44 target: *const std.Build.ResolvedTarget,44 target: *const std.Build.ResolvedTarget,
45 triple: ?[]const u8,45 triple: ?[]const u8,
46) void {46) void {
47 const both_backends = switch (target.result.cpu.arch) {47 const both_backends = b: {
48 .x86_64 => switch (target.result.ofmt) {48 if (comptime builtin.cpu.arch.endian() == .big) break :b false; // https://github.com/ziglang/zig/issues/25961
49 .elf => !target.result.os.tag.isBSD() and target.result.os.tag != .illumos,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 },
50 else => false,54 else => false,
51 },55 };
52 else => false,
53 };56 };
54 const both_pie = switch (target.result.os.tag) {57 const both_pie = switch (target.result.os.tag) {
55 .fuchsia, .openbsd => false,58 .fuchsia, .openbsd => false,
test/tests.zig+1
...@@ -2500,6 +2500,7 @@ fn addOneModuleTest(...@@ -2500,6 +2500,7 @@ fn addOneModuleTest(
2500}2500}
25012501
2502pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {2502pub 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
2503 if (use_llvm) |x| return x;2504 if (use_llvm) |x| return x;
2504 if (query.ofmt == .c) return false;2505 if (query.ofmt == .c) return false;
2505 switch (optimize_mode) {2506 switch (optimize_mode) {