s390x-linux and general big-endian stuff#25965
Merged
alexrp merged 24 commits intoziglang:masterfrom Nov 19, 2025
Merged
Conversation
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).
Member
Author
c52fc95 to
7d17579
Compare
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`.
mlugg
approved these changes
Nov 19, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.