authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-11-19 19:52:18+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2025-11-19 19:52:18+01:00
log43371cf388c66721d9ce1ef6ab397113b5e72608
tree5e3b06c53077ec1648fed5c313f091b57e3aff8f
parent806470b492f15c4e3350ce4a48e607f2c8e94ff8
parentabd05b38195dd8b258505433555e52e3631edcfc
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #25965 from alexrp/s390x

`s390x-linux` and general big-endian stuff

29 files changed, 455 insertions(+), 182 deletions(-)

.forgejo/workflows/ci.yaml+20
......@@ -73,6 +73,26 @@ jobs:
7373 - name: Build and Test
7474 run: sh ci/riscv64-linux-release.sh
7575 timeout-minutes: 420
76 s390x-linux-debug:
77 runs-on: [self-hosted, s390x-linux]
78 steps:
79 - name: Checkout
80 uses: actions/checkout@v4
81 with:
82 fetch-depth: 0
83 - name: Build and Test
84 run: sh ci/s390x-linux-debug.sh
85 timeout-minutes: 240
86 s390x-linux-release:
87 runs-on: [self-hosted, s390x-linux]
88 steps:
89 - name: Checkout
90 uses: actions/checkout@v4
91 with:
92 fetch-depth: 0
93 - name: Build and Test
94 run: sh ci/s390x-linux-release.sh
95 timeout-minutes: 180
7696 x86_64-freebsd-debug:
7797 runs-on: [self-hosted, x86_64-freebsd]
7898 steps:
ci/s390x-linux-debug.sh created+65
......@@ -0,0 +1,65 @@
1#!/bin/sh
2
3# Requires cmake ninja-build
4
5set -x
6set -e
7
8TARGET="s390x-linux-musl"
9MCPU="z15"
10CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.1354+94e98bfe8"
11PREFIX="$HOME/deps/$CACHE_BASENAME"
12ZIG="$PREFIX/bin/zig"
13
14# Override the cache directories because they won't actually help other CI runs
15# which will be testing alternate versions of zig, and ultimately would just
16# fill up space on the hard drive for no reason.
17export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
18export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
19
20mkdir build-debug
21cd build-debug
22
23export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
24export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
25
26cmake .. \
27 -DCMAKE_INSTALL_PREFIX="stage3-debug" \
28 -DCMAKE_PREFIX_PATH="$PREFIX" \
29 -DCMAKE_BUILD_TYPE=Debug \
30 -DZIG_TARGET_TRIPLE="$TARGET" \
31 -DZIG_TARGET_MCPU="$MCPU" \
32 -DZIG_STATIC=ON \
33 -DZIG_NO_LIB=ON \
34 -GNinja \
35 -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \
36 -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE
37# https://github.com/ziglang/zig/issues/22213
38
39# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
40# so that installation and testing do not get affected by them.
41unset CC
42unset CXX
43
44ninja install
45
46# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
47stage3-debug/bin/zig build test docs \
48 --maxrss 30064771072 \
49 -Dstatic-llvm \
50 -Dskip-non-native \
51 -Dtarget=native-native-musl \
52 --search-prefix "$PREFIX" \
53 --zig-lib-dir "$PWD/../lib" \
54 --test-timeout 4m
55
56stage3-debug/bin/zig build \
57 --prefix stage4-debug \
58 -Denable-llvm \
59 -Dno-lib \
60 -Dtarget=$TARGET \
61 -Dcpu=$MCPU \
62 -Duse-zig-libcxx \
63 -Dversion-string="$(stage3-debug/bin/zig version)"
64
65stage4-debug/bin/zig test ../test/behavior.zig
ci/s390x-linux-release.sh created+71
......@@ -0,0 +1,71 @@
1#!/bin/sh
2
3# Requires cmake ninja-build
4
5set -x
6set -e
7
8TARGET="s390x-linux-musl"
9MCPU="z15"
10CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.1354+94e98bfe8"
11PREFIX="$HOME/deps/$CACHE_BASENAME"
12ZIG="$PREFIX/bin/zig"
13
14# Override the cache directories because they won't actually help other CI runs
15# which will be testing alternate versions of zig, and ultimately would just
16# fill up space on the hard drive for no reason.
17export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
18export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
19
20mkdir build-release
21cd build-release
22
23export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
24export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
25
26cmake .. \
27 -DCMAKE_INSTALL_PREFIX="stage3-release" \
28 -DCMAKE_PREFIX_PATH="$PREFIX" \
29 -DCMAKE_BUILD_TYPE=Release \
30 -DZIG_TARGET_TRIPLE="$TARGET" \
31 -DZIG_TARGET_MCPU="$MCPU" \
32 -DZIG_STATIC=ON \
33 -DZIG_NO_LIB=ON \
34 -GNinja \
35 -DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \
36 -DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE
37# https://github.com/ziglang/zig/issues/22213
38
39# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
40# so that installation and testing do not get affected by them.
41unset CC
42unset CXX
43
44ninja install
45
46# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
47stage3-release/bin/zig build test docs \
48 --maxrss 30064771072 \
49 -Dstatic-llvm \
50 -Dskip-non-native \
51 -Dtarget=native-native-musl \
52 --search-prefix "$PREFIX" \
53 --zig-lib-dir "$PWD/../lib" \
54 --test-timeout 4m
55
56# Ensure that stage3 and stage4 are byte-for-byte identical.
57stage3-release/bin/zig build \
58 --prefix stage4-release \
59 -Denable-llvm \
60 -Dno-lib \
61 -Doptimize=ReleaseFast \
62 -Dstrip \
63 -Dtarget=$TARGET \
64 -Dcpu=$MCPU \
65 -Duse-zig-libcxx \
66 -Dversion-string="$(stage3-release/bin/zig version)"
67
68# diff returns an error code if the files differ.
69echo "If the following command fails, it means nondeterminism has been"
70echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
71diff stage3-release/bin/zig stage4-release/bin/zig
doc/langref/runtime_shrExact_overflow.zig+1-1
......@@ -7,7 +7,7 @@ pub fn main() void {
77 const y = @shrExact(x, 2);
88 std.debug.print("value: {}\n", .{y});
99
10 if ((builtin.cpu.arch.isRISCV() or builtin.cpu.arch.isLoongArch()) and builtin.zig_backend == .stage2_llvm) @panic("https://github.com/ziglang/zig/issues/24304");
10 if ((builtin.cpu.arch.isRISCV() or builtin.cpu.arch.isLoongArch() or builtin.cpu.arch == .s390x) and builtin.zig_backend == .stage2_llvm) @panic("https://github.com/ziglang/zig/issues/24304");
1111}
1212
1313// exe=fail
doc/langref/test_defining_variadic_function.zig+4
......@@ -22,6 +22,10 @@ test "defining a variadic function" {
2222 // https://github.com/ziglang/zig/issues/16961
2323 return error.SkipZigTest;
2424 }
25 if (builtin.cpu.arch == .s390x) {
26 // https://github.com/ziglang/zig/issues/21350#issuecomment-3543006475
27 return error.SkipZigTest;
28 }
2529
2630 try std.testing.expectEqual(@as(c_int, 0), add(0));
2731 try std.testing.expectEqual(@as(c_int, 1), add(1, @as(c_int, 1)));
lib/compiler/aro/aro/Compilation.zig+5
......@@ -774,6 +774,11 @@ fn generateSystemDefines(comp: *Compilation, w: *Io.Writer) !void {
774774 try w.print("#define __wasm_{s}__ 1\n", .{feature.name});
775775 }
776776 },
777 .s390x => {
778 try define(w, "__s390__");
779 try define(w, "__s390x__");
780 try define(w, "__zarch__");
781 },
777782 else => {},
778783 }
779784
lib/compiler/std-docs.zig+7-4
......@@ -348,12 +348,12 @@ fn buildWasmBinary(
348348 result_error_bundle = try std.zig.Server.allocErrorBundle(arena, body);
349349 },
350350 .emit_digest => {
351 const EmitDigest = std.zig.Server.Message.EmitDigest;
352 const emit_digest = @as(*align(1) const EmitDigest, @ptrCast(body));
351 var r: std.Io.Reader = .fixed(body);
352 const emit_digest = r.takeStruct(std.zig.Server.Message.EmitDigest, .little) catch unreachable;
353353 if (!emit_digest.flags.cache_hit) {
354354 std.log.info("source changes detected; rebuilt wasm component", .{});
355355 }
356 const digest = body[@sizeOf(EmitDigest)..][0..Cache.bin_digest_len];
356 const digest = r.takeArray(Cache.bin_digest_len) catch unreachable;
357357 result = .{
358358 .root_dir = Cache.Directory.cwd(),
359359 .sub_path = try std.fs.path.join(arena, &.{
......@@ -415,7 +415,10 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
415415 .tag = tag,
416416 .bytes_len = 0,
417417 };
418 try file.writeAll(std.mem.asBytes(&header));
418 var w = file.writer(&.{});
419 w.interface.writeStruct(header, .little) catch |err| switch (err) {
420 error.WriteFailed => return w.err.?,
421 };
419422}
420423
421424fn openBrowserTab(gpa: Allocator, url: []const u8) !void {
lib/std/Build/Step.zig+4-1
......@@ -680,7 +680,10 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
680680 .tag = tag,
681681 .bytes_len = 0,
682682 };
683 try file.writeAll(std.mem.asBytes(&header));
683 var w = file.writer(&.{});
684 w.interface.writeStruct(header, .little) catch |err| switch (err) {
685 error.WriteFailed => return w.err.?,
686 };
684687}
685688
686689pub fn handleVerbose(
lib/std/Build/Step/CheckObject.zig+53-27
......@@ -1857,15 +1857,26 @@ const ElfDumper = struct {
18571857
18581858 fn parseAndDumpObject(step: *Step, check: Check, bytes: []const u8) ![]const u8 {
18591859 const gpa = step.owner.allocator;
1860 var reader: std.Io.Reader = .fixed(bytes);
18611860
1862 const hdr = try reader.takeStruct(elf.Elf64_Ehdr, .little);
1863 if (!mem.eql(u8, hdr.e_ident[0..4], "\x7fELF")) {
1864 return error.InvalidMagicNumber;
1861 // `std.elf.Header` takes care of endianness issues for us.
1862 var reader: std.Io.Reader = .fixed(bytes);
1863 const hdr = try elf.Header.read(&reader);
1864
1865 var shdrs = try gpa.alloc(elf.Elf64_Shdr, hdr.shnum);
1866 defer gpa.free(shdrs);
1867 {
1868 var shdr_it = hdr.iterateSectionHeadersBuffer(bytes);
1869 var shdr_i: usize = 0;
1870 while (try shdr_it.next()) |shdr| : (shdr_i += 1) shdrs[shdr_i] = shdr;
18651871 }
18661872
1867 const shdrs = @as([*]align(1) const elf.Elf64_Shdr, @ptrCast(bytes.ptr + hdr.e_shoff))[0..hdr.e_shnum];
1868 const phdrs = @as([*]align(1) const elf.Elf64_Phdr, @ptrCast(bytes.ptr + hdr.e_phoff))[0..hdr.e_phnum];
1873 var phdrs = try gpa.alloc(elf.Elf64_Phdr, hdr.shnum);
1874 defer gpa.free(phdrs);
1875 {
1876 var phdr_it = hdr.iterateProgramHeadersBuffer(bytes);
1877 var phdr_i: usize = 0;
1878 while (try phdr_it.next()) |phdr| : (phdr_i += 1) phdrs[phdr_i] = phdr;
1879 }
18691880
18701881 var ctx = ObjectContext{
18711882 .gpa = gpa,
......@@ -1875,13 +1886,21 @@ const ElfDumper = struct {
18751886 .phdrs = phdrs,
18761887 .shstrtab = undefined,
18771888 };
1878 ctx.shstrtab = ctx.getSectionContents(ctx.hdr.e_shstrndx);
1889 ctx.shstrtab = ctx.getSectionContents(ctx.hdr.shstrndx);
1890
1891 defer gpa.free(ctx.symtab.symbols);
1892 defer gpa.free(ctx.dysymtab.symbols);
1893 defer gpa.free(ctx.dyns);
18791894
18801895 for (ctx.shdrs, 0..) |shdr, i| switch (shdr.sh_type) {
18811896 elf.SHT_SYMTAB, elf.SHT_DYNSYM => {
18821897 const raw = ctx.getSectionContents(i);
18831898 const nsyms = @divExact(raw.len, @sizeOf(elf.Elf64_Sym));
1884 const symbols = @as([*]align(1) const elf.Elf64_Sym, @ptrCast(raw.ptr))[0..nsyms];
1899 const symbols = try gpa.alloc(elf.Elf64_Sym, nsyms);
1900
1901 var r: std.Io.Reader = .fixed(raw);
1902 for (0..nsyms) |si| symbols[si] = r.takeStruct(elf.Elf64_Sym, ctx.hdr.endian) catch unreachable;
1903
18851904 const strings = ctx.getSectionContents(shdr.sh_link);
18861905
18871906 switch (shdr.sh_type) {
......@@ -1900,6 +1919,17 @@ const ElfDumper = struct {
19001919 else => unreachable,
19011920 }
19021921 },
1922 elf.SHT_DYNAMIC => {
1923 const raw = ctx.getSectionContents(i);
1924 const ndyns = @divExact(raw.len, @sizeOf(elf.Elf64_Dyn));
1925 const dyns = try gpa.alloc(elf.Elf64_Dyn, ndyns);
1926
1927 var r: std.Io.Reader = .fixed(raw);
1928 for (0..ndyns) |si| dyns[si] = r.takeStruct(elf.Elf64_Dyn, ctx.hdr.endian) catch unreachable;
1929
1930 ctx.dyns = dyns;
1931 ctx.dyns_strings = ctx.getSectionContents(shdr.sh_link);
1932 },
19031933
19041934 else => {},
19051935 };
......@@ -1923,9 +1953,9 @@ const ElfDumper = struct {
19231953 try ctx.dumpSymtab(.dysymtab, writer);
19241954 } else return step.fail("no dynamic symbol table found", .{}),
19251955
1926 .dynamic_section => if (ctx.getSectionByName(".dynamic")) |shndx| {
1927 try ctx.dumpDynamicSection(shndx, writer);
1928 } else return step.fail("no .dynamic section found", .{}),
1956 .dynamic_section => if (ctx.dyns.len > 0) {
1957 try ctx.dumpDynamicSection(writer);
1958 } else return step.fail("no dynamic section found", .{}),
19291959
19301960 .dump_section => {
19311961 const name = mem.sliceTo(@as([*:0]const u8, @ptrCast(check.data.items.ptr + check.payload.dump_section)), 0);
......@@ -1942,17 +1972,19 @@ const ElfDumper = struct {
19421972 const ObjectContext = struct {
19431973 gpa: Allocator,
19441974 data: []const u8,
1945 hdr: elf.Elf64_Ehdr,
1946 shdrs: []align(1) const elf.Elf64_Shdr,
1947 phdrs: []align(1) const elf.Elf64_Phdr,
1975 hdr: elf.Header,
1976 shdrs: []const elf.Elf64_Shdr,
1977 phdrs: []const elf.Elf64_Phdr,
19481978 shstrtab: []const u8,
19491979 symtab: Symtab = .{},
19501980 dysymtab: Symtab = .{},
1981 dyns: []const elf.Elf64_Dyn = &.{},
1982 dyns_strings: []const u8 = &.{},
19511983
19521984 fn dumpHeader(ctx: ObjectContext, writer: anytype) !void {
19531985 try writer.writeAll("header\n");
1954 try writer.print("type {s}\n", .{@tagName(ctx.hdr.e_type)});
1955 try writer.print("entry {x}\n", .{ctx.hdr.e_entry});
1986 try writer.print("type {s}\n", .{@tagName(ctx.hdr.type)});
1987 try writer.print("entry {x}\n", .{ctx.hdr.entry});
19561988 }
19571989
19581990 fn dumpPhdrs(ctx: ObjectContext, writer: anytype) !void {
......@@ -2011,16 +2043,10 @@ const ElfDumper = struct {
20112043 }
20122044 }
20132045
2014 fn dumpDynamicSection(ctx: ObjectContext, shndx: usize, writer: anytype) !void {
2015 const shdr = ctx.shdrs[shndx];
2016 const strtab = ctx.getSectionContents(shdr.sh_link);
2017 const data = ctx.getSectionContents(shndx);
2018 const nentries = @divExact(data.len, @sizeOf(elf.Elf64_Dyn));
2019 const entries = @as([*]align(1) const elf.Elf64_Dyn, @ptrCast(data.ptr))[0..nentries];
2020
2046 fn dumpDynamicSection(ctx: ObjectContext, writer: anytype) !void {
20212047 try writer.writeAll(ElfDumper.dynamic_section_label ++ "\n");
20222048
2023 for (entries) |entry| {
2049 for (ctx.dyns) |entry| {
20242050 const key = @as(u64, @bitCast(entry.d_tag));
20252051 const value = entry.d_val;
20262052
......@@ -2067,7 +2093,7 @@ const ElfDumper = struct {
20672093 elf.DT_RPATH,
20682094 elf.DT_RUNPATH,
20692095 => {
2070 const name = getString(strtab, @intCast(value));
2096 const name = getString(ctx.dyns_strings, @intCast(value));
20712097 try writer.print(" {s}", .{name});
20722098 },
20732099
......@@ -2256,8 +2282,8 @@ const ElfDumper = struct {
22562282 };
22572283
22582284 const Symtab = struct {
2259 symbols: []align(1) const elf.Elf64_Sym = &[0]elf.Elf64_Sym{},
2260 strings: []const u8 = &[0]u8{},
2285 symbols: []const elf.Elf64_Sym = &.{},
2286 strings: []const u8 = &.{},
22612287
22622288 fn get(st: Symtab, index: usize) ?elf.Elf64_Sym {
22632289 if (index >= st.symbols.len) return null;
lib/std/Build/Step/Run.zig+44-31
......@@ -1927,6 +1927,7 @@ fn pollZigTest(
19271927 .ns_elapsed = if (timer) |*t| t.read() else 0,
19281928 } };
19291929 const body = stdout.take(header.bytes_len) catch unreachable;
1930 var body_r: std.Io.Reader = .fixed(body);
19301931 switch (header.tag) {
19311932 .zig_version => {
19321933 if (!std.mem.eql(u8, builtin.zig_version_string, body)) return run.step.fail(
......@@ -1942,29 +1943,23 @@ fn pollZigTest(
19421943 // restart the test runner).
19431944 assert(opt_metadata.* == null);
19441945
1945 const TmHdr = std.zig.Server.Message.TestMetadata;
1946 const tm_hdr: *align(1) const TmHdr = @ptrCast(body);
1946 const tm_hdr = body_r.takeStruct(std.zig.Server.Message.TestMetadata, .little) catch unreachable;
19471947 results.test_count = tm_hdr.tests_len;
19481948
1949 const names_bytes = body[@sizeOf(TmHdr)..][0 .. results.test_count * @sizeOf(u32)];
1950 const expected_panic_msgs_bytes = body[@sizeOf(TmHdr) + names_bytes.len ..][0 .. results.test_count * @sizeOf(u32)];
1951 const string_bytes = body[@sizeOf(TmHdr) + names_bytes.len + expected_panic_msgs_bytes.len ..][0..tm_hdr.string_bytes_len];
1949 const names = try arena.alloc(u32, results.test_count);
1950 for (names) |*dest| dest.* = body_r.takeInt(u32, .little) catch unreachable;
19521951
1953 const names = std.mem.bytesAsSlice(u32, names_bytes);
1954 const expected_panic_msgs = std.mem.bytesAsSlice(u32, expected_panic_msgs_bytes);
1952 const expected_panic_msgs = try arena.alloc(u32, results.test_count);
1953 for (expected_panic_msgs) |*dest| dest.* = body_r.takeInt(u32, .little) catch unreachable;
19551954
1956 const names_aligned = try arena.alloc(u32, names.len);
1957 for (names_aligned, names) |*dest, src| dest.* = src;
1958
1959 const expected_panic_msgs_aligned = try arena.alloc(u32, expected_panic_msgs.len);
1960 for (expected_panic_msgs_aligned, expected_panic_msgs) |*dest, src| dest.* = src;
1955 const string_bytes = body_r.take(tm_hdr.string_bytes_len) catch unreachable;
19611956
19621957 options.progress_node.setEstimatedTotalItems(names.len);
19631958 opt_metadata.* = .{
19641959 .string_bytes = try arena.dupe(u8, string_bytes),
19651960 .ns_per_test = try arena.alloc(u64, results.test_count),
1966 .names = names_aligned,
1967 .expected_panic_msgs = expected_panic_msgs_aligned,
1961 .names = names,
1962 .expected_panic_msgs = expected_panic_msgs,
19681963 .next_index = 0,
19691964 .prog_node = options.progress_node,
19701965 };
......@@ -1983,8 +1978,7 @@ fn pollZigTest(
19831978 assert(fuzz_context == null);
19841979 const md = &opt_metadata.*.?;
19851980
1986 const TrHdr = std.zig.Server.Message.TestResults;
1987 const tr_hdr: *align(1) const TrHdr = @ptrCast(body);
1981 const tr_hdr = body_r.takeStruct(std.zig.Server.Message.TestResults, .little) catch unreachable;
19881982 assert(tr_hdr.index == active_test_index);
19891983
19901984 switch (tr_hdr.flags.status) {
......@@ -2026,18 +2020,21 @@ fn pollZigTest(
20262020 requestNextTest(child.stdin.?, md, &sub_prog_node) catch |err| return .{ .write_failed = err };
20272021 },
20282022 .coverage_id => {
2029 const fuzz = fuzz_context.?.fuzz;
2030 const msg_ptr: *align(1) const [4]u64 = @ptrCast(body);
2031 coverage_id = msg_ptr[0];
2023 coverage_id = body_r.takeInt(u64, .little) catch unreachable;
2024 const cumulative_runs = body_r.takeInt(u64, .little) catch unreachable;
2025 const cumulative_unique = body_r.takeInt(u64, .little) catch unreachable;
2026 const cumulative_coverage = body_r.takeInt(u64, .little) catch unreachable;
2027
20322028 {
2029 const fuzz = fuzz_context.?.fuzz;
20332030 fuzz.queue_mutex.lock();
20342031 defer fuzz.queue_mutex.unlock();
20352032 try fuzz.msg_queue.append(fuzz.gpa, .{ .coverage = .{
20362033 .id = coverage_id.?,
20372034 .cumulative = .{
2038 .runs = msg_ptr[1],
2039 .unique = msg_ptr[2],
2040 .coverage = msg_ptr[3],
2035 .runs = cumulative_runs,
2036 .unique = cumulative_unique,
2037 .coverage = cumulative_coverage,
20412038 },
20422039 .run = run,
20432040 } });
......@@ -2046,8 +2043,7 @@ fn pollZigTest(
20462043 },
20472044 .fuzz_start_addr => {
20482045 const fuzz = fuzz_context.?.fuzz;
2049 const msg_ptr: *align(1) const u64 = @ptrCast(body);
2050 const addr = msg_ptr.*;
2046 const addr = body_r.takeInt(u64, .little) catch unreachable;
20512047 {
20522048 fuzz.queue_mutex.lock();
20532049 defer fuzz.queue_mutex.unlock();
......@@ -2116,7 +2112,10 @@ fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void {
21162112 .tag = tag,
21172113 .bytes_len = 0,
21182114 };
2119 try file.writeAll(@ptrCast(&header));
2115 var w = file.writer(&.{});
2116 w.interface.writeStruct(header, .little) catch |err| switch (err) {
2117 error.WriteFailed => return w.err.?,
2118 };
21202119}
21212120
21222121fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index: u32) !void {
......@@ -2124,8 +2123,13 @@ fn sendRunTestMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag, index:
21242123 .tag = tag,
21252124 .bytes_len = 4,
21262125 };
2127 const full_msg = std.mem.asBytes(&header) ++ std.mem.asBytes(&index);
2128 try file.writeAll(full_msg);
2126 var w = file.writer(&.{});
2127 w.interface.writeStruct(header, .little) catch |err| switch (err) {
2128 error.WriteFailed => return w.err.?,
2129 };
2130 w.interface.writeInt(u32, index, .little) catch |err| switch (err) {
2131 error.WriteFailed => return w.err.?,
2132 };
21292133}
21302134
21312135fn sendRunFuzzTestMessage(
......@@ -2138,10 +2142,19 @@ fn sendRunFuzzTestMessage(
21382142 .tag = .start_fuzzing,
21392143 .bytes_len = 4 + 1 + 8,
21402144 };
2141 const full_msg = std.mem.asBytes(&header) ++ std.mem.asBytes(&index) ++
2142 std.mem.asBytes(&kind) ++ std.mem.asBytes(&amount_or_instance);
2143
2144 try file.writeAll(full_msg);
2145 var w = file.writer(&.{});
2146 w.interface.writeStruct(header, .little) catch |err| switch (err) {
2147 error.WriteFailed => return w.err.?,
2148 };
2149 w.interface.writeInt(u32, index, .little) catch |err| switch (err) {
2150 error.WriteFailed => return w.err.?,
2151 };
2152 w.interface.writeByte(@intFromEnum(kind)) catch |err| switch (err) {
2153 error.WriteFailed => return w.err.?,
2154 };
2155 w.interface.writeInt(u64, amount_or_instance, .little) catch |err| switch (err) {
2156 error.WriteFailed => return w.err.?,
2157 };
21452158}
21462159
21472160fn evalGeneric(run: *Run, child: *std.process.Child) !EvalGenericResult {
lib/std/os/linux/IoUring.zig+2
......@@ -4488,6 +4488,8 @@ test "copy_cqes with wrapping sq.cqes buffer" {
44884488}
44894489
44904490test "bind/listen/connect" {
4491 if (builtin.cpu.arch == .s390x) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/25956
4492
44914493 var ring = IoUring.init(4, 0) catch |err| switch (err) {
44924494 error.SystemOutdated => return error.SkipZigTest,
44934495 error.PermissionDenied => return error.SkipZigTest,
lib/std/zig/Server.zig+23-15
......@@ -238,26 +238,34 @@ pub fn serveErrorBundle(s: *Server, error_bundle: std.zig.ErrorBundle) !void {
238238 try s.out.flush();
239239}
240240
241pub fn allocErrorBundle(allocator: std.mem.Allocator, body: []const u8) !std.zig.ErrorBundle {
242 const eb_hdr = @as(*align(1) const OutMessage.ErrorBundle, @ptrCast(body));
243 const extra_bytes =
244 body[@sizeOf(OutMessage.ErrorBundle)..][0 .. @sizeOf(u32) * eb_hdr.extra_len];
245 const string_bytes =
246 body[@sizeOf(OutMessage.ErrorBundle) + extra_bytes.len ..][0..eb_hdr.string_bytes_len];
247 const unaligned_extra: []align(1) const u32 = @ptrCast(extra_bytes);
248
249 var error_bundle: std.zig.ErrorBundle = .{
241pub fn allocErrorBundle(gpa: std.mem.Allocator, body: []const u8) error{ OutOfMemory, EndOfStream }!std.zig.ErrorBundle {
242 var r: Reader = .fixed(body);
243 const hdr = r.takeStruct(OutMessage.ErrorBundle, .little) catch |err| switch (err) {
244 error.EndOfStream => |e| return e,
245 error.ReadFailed => unreachable,
246 };
247
248 var eb: std.zig.ErrorBundle = .{
250249 .string_bytes = &.{},
251250 .extra = &.{},
252251 };
253 errdefer error_bundle.deinit(allocator);
252 errdefer eb.deinit(gpa);
253
254 const extra = try gpa.alloc(u32, hdr.extra_len);
255 eb.extra = extra;
256 const string_bytes = try gpa.alloc(u8, hdr.string_bytes_len);
257 eb.string_bytes = string_bytes;
254258
255 error_bundle.string_bytes = try allocator.dupe(u8, string_bytes);
256 const extra = try allocator.alloc(u32, unaligned_extra.len);
257 @memcpy(extra, unaligned_extra);
258 error_bundle.extra = extra;
259 r.readSliceEndian(u32, extra, .little) catch |err| switch (err) {
260 error.EndOfStream => |e| return e,
261 error.ReadFailed => unreachable,
262 };
263 r.readSliceAll(string_bytes) catch |err| switch (err) {
264 error.EndOfStream => |e| return e,
265 error.ReadFailed => unreachable,
266 };
259267
260 return error_bundle;
268 return eb;
261269}
262270
263271pub const TestMetadata = struct {
lib/std/zon/parse.zig+1
......@@ -3129,6 +3129,7 @@ test "std.zon free on error" {
31293129
31303130test "std.zon vector" {
31313131 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // https://github.com/ziglang/zig/issues/15330
3132 if (builtin.zig_backend == .stage2_llvm and builtin.cpu.arch == .s390x) return error.SkipZigTest; // github.com/ziglang/zig/issues/25957
31323133
31333134 const gpa = std.testing.allocator;
31343135
src/codegen/c.zig+26-10
......@@ -5084,16 +5084,32 @@ fn bitcast(f: *Function, dest_ty: Type, operand: CValue, operand_ty: Type) !CVal
50845084 } else operand;
50855085
50865086 const local = try f.allocLocal(null, dest_ty);
5087 try w.writeAll("memcpy(&");
5088 try f.writeCValue(w, local, .Other);
5089 try w.writeAll(", &");
5090 try f.writeCValue(w, operand_lval, .Other);
5091 try w.writeAll(", sizeof(");
5092 try f.renderType(
5093 w,
5094 if (dest_ty.abiSize(zcu) <= operand_ty.abiSize(zcu)) dest_ty else operand_ty,
5095 );
5096 try w.writeAll("));");
5087 // On big-endian targets, copying ABI integers with padding bits is awkward, because the padding bits are at the low bytes of the value.
5088 // We need to offset the source or destination pointer appropriately and copy the right number of bytes.
5089 if (target.cpu.arch.endian() == .big and dest_ty.isAbiInt(zcu) and !operand_ty.isAbiInt(zcu)) {
5090 // e.g. [10]u8 -> u80. We need to offset the destination so that we copy to the least significant bits of the integer.
5091 const offset = dest_ty.abiSize(zcu) - operand_ty.abiSize(zcu);
5092 try w.writeAll("memcpy((char *)&");
5093 try f.writeCValue(w, local, .Other);
5094 try w.print(" + {d}, &", .{offset});
5095 try f.writeCValue(w, operand_lval, .Other);
5096 try w.print(", {d});", .{operand_ty.abiSize(zcu)});
5097 } else if (target.cpu.arch.endian() == .big and operand_ty.isAbiInt(zcu) and !dest_ty.isAbiInt(zcu)) {
5098 // e.g. u80 -> [10]u8. We need to offset the source so that we copy from the least significant bits of the integer.
5099 const offset = operand_ty.abiSize(zcu) - dest_ty.abiSize(zcu);
5100 try w.writeAll("memcpy(&");
5101 try f.writeCValue(w, local, .Other);
5102 try w.writeAll(", (const char *)&");
5103 try f.writeCValue(w, operand_lval, .Other);
5104 try w.print(" + {d}, {d});", .{ offset, dest_ty.abiSize(zcu) });
5105 } else {
5106 try w.writeAll("memcpy(&");
5107 try f.writeCValue(w, local, .Other);
5108 try w.writeAll(", &");
5109 try f.writeCValue(w, operand_lval, .Other);
5110 try w.print(", {d});", .{@min(dest_ty.abiSize(zcu), operand_ty.abiSize(zcu))});
5111 }
5112
50975113 try f.object.newline();
50985114
50995115 // Ensure padding bits have the expected value.
src/codegen/llvm.zig+9-22
......@@ -3651,35 +3651,22 @@ pub const Object = struct {
36513651 .opt => {}, // pointer like optional expected
36523652 else => unreachable,
36533653 }
3654 const bits = ty.bitSize(zcu);
3655 const bytes: usize = @intCast(std.mem.alignForward(u64, bits, 8) / 8);
3656
36573654 var stack = std.heap.stackFallback(32, o.gpa);
36583655 const allocator = stack.get();
36593656
3660 const limbs = try allocator.alloc(
3661 std.math.big.Limb,
3662 std.mem.alignForward(usize, bytes, @sizeOf(std.math.big.Limb)) /
3663 @sizeOf(std.math.big.Limb),
3664 );
3657 const bits: usize = @intCast(ty.bitSize(zcu));
3658
3659 const buffer = try allocator.alloc(u8, (bits + 7) / 8);
3660 defer allocator.free(buffer);
3661 const limbs = try allocator.alloc(std.math.big.Limb, std.math.big.int.calcTwosCompLimbCount(bits));
36653662 defer allocator.free(limbs);
3666 @memset(limbs, 0);
36673663
3668 val.writeToPackedMemory(ty, pt, std.mem.sliceAsBytes(limbs)[0..bytes], 0) catch unreachable;
3664 val.writeToPackedMemory(ty, pt, buffer, 0) catch unreachable;
36693665
3670 if (builtin.target.cpu.arch.endian() == .little) {
3671 if (target.cpu.arch.endian() == .big)
3672 std.mem.reverse(u8, std.mem.sliceAsBytes(limbs)[0..bytes]);
3673 } else if (target.cpu.arch.endian() == .little) {
3674 for (limbs) |*limb| {
3675 limb.* = std.mem.nativeToLittle(usize, limb.*);
3676 }
3677 }
3666 var big: std.math.big.int.Mutable = .init(limbs, 0);
3667 big.readTwosComplement(buffer, bits, target.cpu.arch.endian(), .unsigned);
36783668
3679 return o.builder.bigIntConst(llvm_int_ty, .{
3680 .limbs = limbs,
3681 .positive = true,
3682 });
3669 return o.builder.bigIntConst(llvm_int_ty, big.toConst());
36833670 }
36843671
36853672 fn lowerValue(o: *Object, pt: Zcu.PerThread, arg_val: InternPool.Index) Error!Builder.Constant {
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) {
stage1/zig.h+4-2
......@@ -28,6 +28,8 @@
2828#define zig_arm
2929#elif defined(__hexagon__)
3030#define zig_hexagon
31#elif defined(__kvx__)
32#define zig_kvx
3133#elif defined(__loongarch32)
3234#define zig_loongarch32
3335#define zig_loongarch
......@@ -383,7 +385,7 @@
383385#define zig_trap() __asm__ volatile("udf #0xfdee")
384386#elif defined(zig_hexagon)
385387#define zig_trap() __asm__ volatile("r27:26 = memd(#0xbadc0fee)")
386#elif defined(zig_loongarch) || defined(zig_powerpc)
388#elif defined(zig_kvx) || defined(zig_loongarch) || defined(zig_powerpc)
387389#define zig_trap() __asm__ volatile(".word 0x0")
388390#elif defined(zig_mips)
389391#define zig_trap() __asm__ volatile(".word 0x3d")
......@@ -419,7 +421,7 @@
419421#define zig_breakpoint() __asm__ volatile("brk #0xf000")
420422#elif defined(zig_hexagon)
421423#define zig_breakpoint() __asm__ volatile("brkpt")
422#elif defined(zig_loongarch)
424#elif defined(zig_kvx) || defined(zig_loongarch)
423425#define zig_breakpoint() __asm__ volatile("break 0x0")
424426#elif defined(zig_mips)
425427#define zig_breakpoint() __asm__ volatile("break")
stage1/zig1.wasm
Binary files a/stage1/zig1.wasm and b/stage1/zig1.wasm differ
test/c_abi/cfuncs.c+15-9
......@@ -77,6 +77,10 @@ static void assert_or_panic(bool ok) {
7777# define ZIG_NO_COMPLEX
7878#endif
7979
80#ifdef __s390x__
81# define ZIG_NO_COMPLEX
82#endif
83
8084#ifdef __x86_64__
8185#define ZIG_NO_RAW_F16
8286#endif
......@@ -2728,7 +2732,7 @@ void run_c_tests(void) {
27282732 }
27292733#endif
27302734
2731#if !defined(ZIG_PPC32) && !defined(__hexagon__)
2735#if !defined(ZIG_PPC32) && !defined(__hexagon__) && !defined(__s390x__)
27322736 {
27332737 struct Struct_u64_u64 s = zig_ret_struct_u64_u64();
27342738 assert_or_panic(s.a == 1);
......@@ -2807,7 +2811,7 @@ void run_c_tests(void) {
28072811
28082812#if !defined __i386__ && !defined __arm__ && !defined __aarch64__ && \
28092813 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2810 !defined(__mips64__) && !defined(__hexagon__)
2814 !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__)
28112815 {
28122816 struct SmallStructInts s = {1, 2, 3, 4};
28132817 zig_small_struct_ints(s);
......@@ -2816,7 +2820,7 @@ void run_c_tests(void) {
28162820
28172821#if !defined __arm__ && !defined __aarch64__ && \
28182822 !defined __powerpc__ && !defined ZIG_RISCV64 && !defined(__loongarch__) && \
2819 !defined(__mips64__) && !defined(__hexagon__)
2823 !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__)
28202824 {
28212825 struct MedStructInts s = {1, 2, 3};
28222826 zig_med_struct_ints(s);
......@@ -2843,7 +2847,7 @@ void run_c_tests(void) {
28432847
28442848#if !defined __i386__ && !defined __arm__ && \
28452849 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2846 !defined(__mips64__) && !defined(__hexagon__)
2850 !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__)
28472851 {
28482852 struct SplitStructInts s = {1234, 100, 1337};
28492853 zig_split_struct_ints(s);
......@@ -2851,7 +2855,7 @@ void run_c_tests(void) {
28512855#endif
28522856
28532857#if !defined __arm__ && !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2854 !defined(__mips64__) && !defined(__hexagon__)
2858 !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__)
28552859 {
28562860 struct MedStructMixed s = {1234, 100.0f, 1337.0f};
28572861 zig_med_struct_mixed(s);
......@@ -2860,14 +2864,15 @@ void run_c_tests(void) {
28602864
28612865#if !defined __i386__ && !defined __arm__ && \
28622866 !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && \
2863 !defined(__mips64__) && !defined(__hexagon__)
2867 !defined(__mips64__) && !defined(__hexagon__) && !defined(__s390x__)
28642868 {
28652869 struct SplitStructMixed s = {1234, 100, 1337.0f};
28662870 zig_split_struct_mixed(s);
28672871 }
28682872#endif
28692873
2870#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__)
2874#if !defined(__powerpc__) && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__) && \
2875 !defined(__s390x__)
28712876 {
28722877 struct BigStruct s = {30, 31, 32, 33, 34};
28732878 struct BigStruct res = zig_big_struct_both(s);
......@@ -2880,7 +2885,7 @@ void run_c_tests(void) {
28802885#endif
28812886
28822887#if !defined ZIG_PPC32 && !defined _ARCH_PPC64 && !defined(__loongarch__) && !defined(__mips64__) && \
2883 !defined(__hexagon__)
2888 !defined(__hexagon__) && !defined(__s390x__)
28842889 {
28852890 struct Rect r1 = {1, 21, 16, 4};
28862891 struct Rect r2 = {178, 189, 21, 15};
......@@ -2888,7 +2893,8 @@ void run_c_tests(void) {
28882893 }
28892894#endif
28902895
2891#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__)
2896#if !defined ZIG_PPC32 && !defined(__loongarch__) && !defined(__mips64__) && !defined(__hexagon__) && \
2897 !defined(__s390x__)
28922898 {
28932899 struct FloatRect r1 = {1, 21, 16, 4};
28942900 struct FloatRect r2 = {178, 189, 21, 15};
test/c_abi/main.zig+46-2
......@@ -12,7 +12,8 @@ const expect = std.testing.expect;
1212const expectEqual = std.testing.expectEqual;
1313const have_i128 = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isArm() and
1414 !builtin.cpu.arch.isMIPS() and !builtin.cpu.arch.isPowerPC32() and builtin.cpu.arch != .riscv32 and
15 builtin.cpu.arch != .hexagon;
15 builtin.cpu.arch != .hexagon and
16 builtin.cpu.arch != .s390x; // https://github.com/llvm/llvm-project/issues/168460
1617
1718const have_f128 = builtin.cpu.arch.isWasm() or (builtin.cpu.arch.isX86() and !builtin.os.tag.isDarwin());
1819const have_f80 = builtin.cpu.arch.isX86();
......@@ -185,7 +186,8 @@ extern fn c_cmultd(a: ComplexDouble, b: ComplexDouble) ComplexDouble;
185186
186187const complex_abi_compatible = builtin.cpu.arch != .x86 and !builtin.cpu.arch.isMIPS() and
187188 !builtin.cpu.arch.isArm() and !builtin.cpu.arch.isPowerPC32() and !builtin.cpu.arch.isRISCV() and
188 builtin.cpu.arch != .hexagon;
189 builtin.cpu.arch != .hexagon and
190 builtin.cpu.arch != .s390x;
189191
190192test "C ABI complex float" {
191193 if (!complex_abi_compatible) return error.SkipZigTest;
......@@ -329,6 +331,7 @@ test "C ABI struct u64 u64" {
329331 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
330332 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
331333 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
334 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
332335
333336 const s = c_ret_struct_u64_u64();
334337 try expect(s.a == 21);
......@@ -363,6 +366,7 @@ extern fn c_struct_f32(Struct_f32) void;
363366test "C ABI struct f32" {
364367 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
365368 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
369 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
366370
367371 const s = c_ret_struct_f32();
368372 try expect(s.a == 2.5);
......@@ -390,6 +394,7 @@ test "C ABI struct f64" {
390394 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
391395 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
392396 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
397 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
393398
394399 const s = c_ret_struct_f64();
395400 try expect(s.a == 2.5);
......@@ -421,6 +426,7 @@ test "C ABI struct {f32,f32} f32" {
421426 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
422427 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
423428 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
429 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
424430
425431 const s = c_ret_struct_f32f32_f32();
426432 try expect(s.a.b == 1.0);
......@@ -454,6 +460,7 @@ test "C ABI struct f32 {f32,f32}" {
454460 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
455461 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
456462 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
463 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
457464
458465 const s = c_ret_struct_f32_f32f32();
459466 try expect(s.a == 1.0);
......@@ -491,6 +498,7 @@ test "C ABI struct{u32,union{u32,struct{u32,u32}}}" {
491498 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
492499 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
493500 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
501 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
494502
495503 const s = c_ret_struct_u32_union_u32_u32u32();
496504 try expect(s.a == 1);
......@@ -511,6 +519,7 @@ test "C ABI struct i32 i32" {
511519 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
512520 if (builtin.cpu.arch == .riscv32) return error.SkipZigTest;
513521 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
522 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
514523
515524 const s: Struct_i32_i32 = .{
516525 .a = 1,
......@@ -543,6 +552,7 @@ test "C ABI big struct" {
543552 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
544553 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
545554 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
555 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
546556
547557 const s = BigStruct{
548558 .a = 1,
......@@ -571,6 +581,7 @@ test "C ABI big union" {
571581 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
572582 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
573583 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
584 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
574585
575586 const x = BigUnion{
576587 .a = BigStruct{
......@@ -606,6 +617,7 @@ test "C ABI medium struct of ints and floats" {
606617 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
607618 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
608619 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
620 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
609621
610622 const s = MedStructMixed{
611623 .a = 1234,
......@@ -641,6 +653,7 @@ test "C ABI small struct of ints" {
641653 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
642654 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
643655 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
656 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
644657
645658 const s = SmallStructInts{
646659 .a = 1,
......@@ -676,6 +689,7 @@ test "C ABI medium struct of ints" {
676689 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
677690 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
678691 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
692 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
679693
680694 const s = MedStructInts{
681695 .x = 1,
......@@ -756,6 +770,7 @@ test "C ABI split struct of ints" {
756770 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
757771 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
758772 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
773 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
759774
760775 const s = SplitStructInt{
761776 .a = 1234,
......@@ -785,6 +800,7 @@ test "C ABI split struct of ints and floats" {
785800 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
786801 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
787802 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
803 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
788804
789805 const s = SplitStructMixed{
790806 .a = 1234,
......@@ -814,6 +830,7 @@ test "C ABI sret and byval together" {
814830 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
815831 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
816832 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
833 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
817834
818835 const s = BigStruct{
819836 .a = 1,
......@@ -868,6 +885,7 @@ test "C ABI structs of floats as parameter" {
868885 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
869886 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
870887 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
888 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
871889
872890 const v3 = Vector3{
873891 .x = 3.0,
......@@ -910,6 +928,7 @@ test "C ABI structs of ints as multiple parameters" {
910928 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
911929 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
912930 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
931 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
913932
914933 const r1 = Rect{
915934 .left = 1,
......@@ -949,6 +968,7 @@ test "C ABI structs of floats as multiple parameters" {
949968 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
950969 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
951970 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
971 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
952972
953973 const r1 = FloatRect{
954974 .left = 1,
......@@ -1064,6 +1084,7 @@ test "Struct with array as padding." {
10641084 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
10651085 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
10661086 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
1087 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
10671088
10681089 c_struct_with_array(.{ .a = 1, .padding = undefined, .b = 2 });
10691090
......@@ -1091,6 +1112,7 @@ test "Float array like struct" {
10911112 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
10921113 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
10931114 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
1115 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
10941116
10951117 c_float_array_struct(.{
10961118 .origin = .{
......@@ -1119,6 +1141,7 @@ test "small simd vector" {
11191141 if (builtin.cpu.arch == .x86) return error.SkipZigTest;
11201142 if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;
11211143 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
1144 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
11221145
11231146 c_small_vec(.{ 1, 2 });
11241147
......@@ -1136,6 +1159,7 @@ test "medium simd vector" {
11361159 if (builtin.zig_backend == .stage2_x86_64 and !comptime builtin.cpu.has(.x86, .avx)) return error.SkipZigTest;
11371160 if (builtin.cpu.arch.isPowerPC64()) return error.SkipZigTest;
11381161 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
1162 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
11391163
11401164 c_medium_vec(.{ 1, 2, 3, 4 });
11411165
......@@ -1184,6 +1208,7 @@ extern fn c_ret_vector_4_float() Vector4Float;
11841208test "float simd vectors" {
11851209 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
11861210 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
1211 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
11871212
11881213 {
11891214 c_vector_2_float(.{ 1.0, 2.0 });
......@@ -5469,6 +5494,7 @@ test "C ABI pointer sized float struct" {
54695494 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
54705495 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
54715496 if (builtin.cpu.arch.isArm() and builtin.abi.float() == .soft) return error.SkipZigTest;
5497 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
54725498
54735499 c_ptr_size_float_struct(.{ .x = 1, .y = 2 });
54745500
......@@ -5493,6 +5519,7 @@ test "DC: Zig passes to C" {
54935519 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
54945520 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
54955521 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5522 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
54965523 try expectOk(c_assert_DC(.{ .v1 = -0.25, .v2 = 15 }));
54975524}
54985525test "DC: Zig returns to C" {
......@@ -5500,6 +5527,7 @@ test "DC: Zig returns to C" {
55005527 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
55015528 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55025529 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5530 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55035531 try expectOk(c_assert_ret_DC());
55045532}
55055533test "DC: C passes to Zig" {
......@@ -5508,6 +5536,7 @@ test "DC: C passes to Zig" {
55085536 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55095537 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55105538 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5539 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55115540 try expectOk(c_send_DC());
55125541}
55135542test "DC: C returns to Zig" {
......@@ -5515,6 +5544,7 @@ test "DC: C returns to Zig" {
55155544 if (builtin.cpu.arch.isRISCV()) return error.SkipZigTest;
55165545 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55175546 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5547 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55185548 try expectEqual(DC{ .v1 = -0.25, .v2 = 15 }, c_ret_DC());
55195549}
55205550
......@@ -5542,12 +5572,14 @@ test "CFF: Zig passes to C" {
55425572 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55435573 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55445574 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5575 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55455576 try expectOk(c_assert_CFF(.{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }));
55465577}
55475578test "CFF: Zig returns to C" {
55485579 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55495580 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55505581 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5582 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55515583 try expectOk(c_assert_ret_CFF());
55525584}
55535585test "CFF: C passes to Zig" {
......@@ -5558,6 +5590,7 @@ test "CFF: C passes to Zig" {
55585590 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55595591 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55605592 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5593 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55615594
55625595 try expectOk(c_send_CFF());
55635596}
......@@ -5567,6 +5600,7 @@ test "CFF: C returns to Zig" {
55675600 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
55685601 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55695602 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5603 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55705604 try expectEqual(CFF{ .v1 = 39, .v2 = 0.875, .v3 = 1.0 }, c_ret_CFF());
55715605}
55725606pub extern fn c_assert_CFF(lv: CFF) c_int;
......@@ -5593,12 +5627,14 @@ test "PD: Zig passes to C" {
55935627 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
55945628 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
55955629 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5630 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
55965631 try expectOk(c_assert_PD(.{ .v1 = null, .v2 = 0.5 }));
55975632}
55985633test "PD: Zig returns to C" {
55995634 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
56005635 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
56015636 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5637 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
56025638 try expectOk(c_assert_ret_PD());
56035639}
56045640test "PD: C passes to Zig" {
......@@ -5606,12 +5642,14 @@ test "PD: C passes to Zig" {
56065642 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
56075643 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
56085644 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5645 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
56095646 try expectOk(c_send_PD());
56105647}
56115648test "PD: C returns to Zig" {
56125649 if (builtin.cpu.arch.isMIPS64()) return error.SkipZigTest;
56135650 if (builtin.cpu.arch.isPowerPC()) return error.SkipZigTest;
56145651 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5652 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
56155653 try expectEqual(PD{ .v1 = null, .v2 = 0.5 }, c_ret_PD());
56165654}
56175655pub extern fn c_assert_PD(lv: PD) c_int;
......@@ -5645,6 +5683,7 @@ extern fn c_modify_by_ref_param(ByRef) ByRef;
56455683test "C function modifies by ref param" {
56465684 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
56475685 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
5686 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
56485687
56495688 const res = c_modify_by_ref_param(.{ .val = 1, .arr = undefined });
56505689 try expect(res.val == 42);
......@@ -5669,6 +5708,7 @@ test "C function that takes byval struct called via function pointer" {
56695708 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
56705709 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
56715710 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5711 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
56725712
56735713 var fn_ptr = &c_func_ptr_byval;
56745714 _ = &fn_ptr;
......@@ -5701,6 +5741,7 @@ test "f16 struct" {
57015741 if (builtin.target.cpu.arch.isMIPS64()) return error.SkipZigTest;
57025742 if (builtin.target.cpu.arch.isPowerPC32()) return error.SkipZigTest;
57035743 if (builtin.cpu.arch.isArm() and builtin.mode != .Debug) return error.SkipZigTest;
5744 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
57045745
57055746 const a = c_f16_struct(.{ .a = 12 });
57065747 try expect(a.a == 34);
......@@ -5810,6 +5851,7 @@ test "Stdcall ABI structs" {
58105851 if (builtin.cpu.arch == .aarch64_be) return error.SkipZigTest;
58115852 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
58125853 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5854 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
58135855
58145856 const res = stdcall_coord2(
58155857 .{ .x = 0x1111, .y = 0x2222 },
......@@ -5825,6 +5867,7 @@ test "Stdcall ABI big union" {
58255867 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
58265868 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
58275869 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5870 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
58285871
58295872 const x = BigUnion{
58305873 .a = BigStruct{
......@@ -5899,6 +5942,7 @@ test "byval tail callsite attribute" {
58995942 if (builtin.cpu.arch.isPowerPC32()) return error.SkipZigTest;
59005943 if (builtin.cpu.arch.isLoongArch()) return error.SkipZigTest;
59015944 if (builtin.cpu.arch == .hexagon) return error.SkipZigTest;
5945 if (builtin.cpu.arch == .s390x) return error.SkipZigTest;
59025946
59035947 // Originally reported at https://github.com/ziglang/zig/issues/16290
59045948 // the bug was that the extern function had the byval attribute, but
test/error_traces.zig+1
......@@ -437,6 +437,7 @@ pub fn addCases(cases: *@import("tests.zig").ErrorTracesContext) void {
437437 .{ .aarch64, .linux },
438438 .{ .loongarch64, .linux },
439439 .{ .riscv64, .linux },
440 .{ .s390x, .linux },
440441 .{ .x86_64, .windows },
441442 .{ .x86, .windows },
442443 .{ .x86_64, .macos },
test/link/elf.zig+3
......@@ -5,6 +5,9 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
55 // https://github.com/ziglang/zig/issues/25323
66 if (builtin.os.tag == .freebsd) return elf_step;
77
8 // https://github.com/ziglang/zig/issues/25961
9 if (comptime builtin.cpu.arch.endian() == .big) return elf_step;
10
811 const default_target = b.resolveTargetQuery(.{
912 .cpu_arch = .x86_64, // TODO relax this once ELF linker is able to handle other archs
1013 .os_tag = .linux,
test/link/macho.zig+3
......@@ -6,6 +6,9 @@ pub fn testAll(b: *Build, build_opts: BuildOptions) *Step {
66 // https://github.com/ziglang/zig/issues/25323
77 if (builtin.os.tag == .freebsd) return macho_step;
88
9 // https://github.com/ziglang/zig/issues/25961
10 if (comptime builtin.cpu.arch.endian() == .big) return macho_step;
11
912 const x86_64_target = b.resolveTargetQuery(.{
1013 .cpu_arch = .x86_64,
1114 .os_tag = .macos,
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/standalone/c_compiler/test.c-25
......@@ -25,30 +25,5 @@ int main (int argc, char *argv[])
2525
2626 if (!ok) abort();
2727
28 // Test some basic arithmetic from compiler-rt
29 {
30 double complex z = 0.0 + I * 4.0;
31 double complex w = 0.0 + I * 16.0;
32 double complex product = z * w;
33 double complex quotient = z / w;
34
35 if (!(creal(product) == -64.0)) abort();
36 if (!(cimag(product) == 0.0)) abort();
37 if (!(creal(quotient) == 0.25)) abort();
38 if (!(cimag(quotient) == 0.0)) abort();
39 }
40
41 {
42 float complex z = 4.0 + I * 4.0;
43 float complex w = 2.0 - I * 2.0;
44 float complex product = z * w;
45 float complex quotient = z / w;
46
47 if (!(creal(product) == 16.0)) abort();
48 if (!(cimag(product) == 0.0)) abort();
49 if (!(creal(quotient) == 0.0)) abort();
50 if (!(cimag(quotient) == 2.0)) abort();
51 }
52
5328 return EXIT_SUCCESS;
5429}
test/standalone/glibc_compat/build.zig+16-12
......@@ -141,12 +141,14 @@ pub fn build(b: *std.Build) void {
141141 check.checkInDynamicSymtab();
142142 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT powf");
143143
144 // An atexit local symbol is defined, and depends on undefined dynamic
145 // __cxa_atexit.
146 check.checkInSymtab();
147 check.checkContains("FUNC LOCAL HIDDEN atexit");
148 check.checkInDynamicSymtab();
149 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT __cxa_atexit");
144 if (target.result.cpu.arch != .s390x) {
145 // An atexit local symbol is defined, and depends on undefined dynamic
146 // __cxa_atexit.
147 check.checkInSymtab();
148 check.checkContains("FUNC LOCAL HIDDEN atexit");
149 check.checkInDynamicSymtab();
150 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT __cxa_atexit");
151 }
150152
151153 test_step.dependOn(&check.step);
152154 }
......@@ -250,12 +252,14 @@ pub fn build(b: *std.Build) void {
250252 check.checkInDynamicSymtab();
251253 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT exit");
252254
253 // An atexit local symbol is defined, and depends on undefined dynamic
254 // __cxa_atexit.
255 check.checkInSymtab();
256 check.checkContains("FUNC LOCAL HIDDEN atexit");
257 check.checkInDynamicSymtab();
258 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT __cxa_atexit");
255 if (target.result.cpu.arch != .s390x) {
256 // An atexit local symbol is defined, and depends on undefined dynamic
257 // __cxa_atexit.
258 check.checkInSymtab();
259 check.checkContains("FUNC LOCAL HIDDEN atexit");
260 check.checkInDynamicSymtab();
261 check.checkExact("0 0 UND FUNC GLOBAL DEFAULT __cxa_atexit");
262 }
259263
260264 test_step.dependOn(&check.step);
261265 }
test/tests.zig+8-8
......@@ -1756,14 +1756,13 @@ const c_abi_targets = blk: {
17561756 },
17571757 },
17581758
1759 // Clang explodes when parsing `cfuncs.c`.
1760 // .{
1761 // .target = .{
1762 // .cpu_arch = .s390x,
1763 // .os_tag = .linux,
1764 // .abi = .musl,
1765 // },
1766 // },
1759 .{
1760 .target = .{
1761 .cpu_arch = .s390x,
1762 .os_tag = .linux,
1763 .abi = .musl,
1764 },
1765 },
17671766
17681767 .{
17691768 .target = std.Target.Query.parse(.{
......@@ -2500,6 +2499,7 @@ fn addOneModuleTest(
25002499}
25012500
25022501pub fn wouldUseLlvm(use_llvm: ?bool, query: std.Target.Query, optimize_mode: OptimizeMode) bool {
2502 if (comptime builtin.cpu.arch.endian() == .big) return true; // https://github.com/ziglang/zig/issues/25961
25032503 if (use_llvm) |x| return x;
25042504 if (query.ofmt == .c) return false;
25052505 switch (optimize_mode) {
tools/incr-check.zig+13-8
......@@ -290,9 +290,8 @@ const Eval = struct {
290290 return;
291291 },
292292 .emit_digest => {
293 const EbpHdr = std.zig.Server.Message.EmitDigest;
294 const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body));
295 _ = ebp_hdr;
293 var r: std.Io.Reader = .fixed(body);
294 _ = r.takeStruct(std.zig.Server.Message.EmitDigest, .little) catch unreachable;
296295 if (stderr.bufferedLen() > 0) {
297296 const stderr_data = try poller.toOwnedSlice(.stderr);
298297 if (eval.allow_stderr) {
......@@ -307,7 +306,7 @@ const Eval = struct {
307306 // This message indicates the end of the update.
308307 }
309308
310 const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len];
309 const digest = r.takeArray(Cache.bin_digest_len) catch unreachable;
311310 const result_dir = ".local-cache" ++ std.fs.path.sep_str ++ "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*);
312311
313312 const bin_name = try std.zig.EmitArtifact.bin.cacheName(arena, .{
......@@ -519,7 +518,10 @@ const Eval = struct {
519518 .tag = .update,
520519 .bytes_len = 0,
521520 };
522 try eval.child.stdin.?.writeAll(std.mem.asBytes(&header));
521 var w = eval.child.stdin.?.writer(&.{});
522 w.interface.writeStruct(header, .little) catch |err| switch (err) {
523 error.WriteFailed => return w.err.?,
524 };
523525 }
524526
525527 fn end(eval: *Eval, poller: *Poller) !void {
......@@ -836,9 +838,12 @@ fn requestExit(child: *std.process.Child, eval: *Eval) void {
836838 .tag = .exit,
837839 .bytes_len = 0,
838840 };
839 child.stdin.?.writeAll(std.mem.asBytes(&header)) catch |err| switch (err) {
840 error.BrokenPipe => {},
841 else => eval.fatal("failed to send exit: {s}", .{@errorName(err)}),
841 var w = eval.child.stdin.?.writer(&.{});
842 w.interface.writeStruct(header, .little) catch |err| switch (err) {
843 error.WriteFailed => switch (w.err.?) {
844 error.BrokenPipe => {},
845 else => |e| eval.fatal("failed to send exit: {s}", .{@errorName(e)}),
846 },
842847 };
843848
844849 // Send EOF to stdin.