Skip to content

s390x-linux and general big-endian stuff#25965

Merged
alexrp merged 24 commits intoziglang:masterfrom
alexrp:s390x
Nov 19, 2025
Merged

s390x-linux and general big-endian stuff#25965
alexrp merged 24 commits intoziglang:masterfrom
alexrp:s390x

Conversation

@alexrp
Copy link
Member

@alexrp alexrp commented Nov 18, 2025

No description provided.

Integers with padding bits on big-endian targets cannot quite be bitcast
with a trivial memcpy, because the padding bits (which are zext or sext)
are the most-significant, so are at the *lowest* addresses. So to
bitcast to something which doesn't have padding bits, we need to offset
past the padding.

The logic I've added here definitely doesn't handle all possibilities
correctly; I think that would actually be quite complicated. However, it
handles a common case, and so prevents the Zig compiler itself from
being miscompiled on big-endian targets (hence fixing a bootstrapping
problem on big-endian).
@alexrp alexrp requested a review from mlugg November 18, 2025 10:13
@alexrp
Copy link
Member Author

alexrp commented Nov 18, 2025

@Vexu FYI 1ccd3c9

@alexrp alexrp force-pushed the s390x branch 2 times, most recently from c52fc95 to 7d17579 Compare November 18, 2025 22:37
mlugg and others added 21 commits November 19, 2025 01:42
The big-endian logic here was simply incorrect. Luckily, it was also
overcomplicated; after calling `Value.writeToPackedMemory`, there is a
method on `std.math.big.int.Mutable` which just does the correct
endianness load for us.
Signed-off-by: Alex Rønne Petersen <alex@alexrp.com>
Again, `std.zig.Server` expects little-endian. This is easy; we just use
a `Reader.fixed` instead of directly `@ptrCast`ing data out of the
buffer.
Little-endian is what `std.zig.Server` expects, but the old logic just
send the raw bytes of the struct, so sent in native endian (causing a
crash on big-endian targets).
…test

This has no business being here. Tests for our compiler-rt routines should be in
compiler-rt, and tests for our C ABI compliance should be in `test-c-abi`.
@alexrp alexrp merged commit 43371cf into ziglang:master Nov 19, 2025
9 checks passed
@alexrp alexrp deleted the s390x branch November 19, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants