Repository navigation
Conversation
tombl
force-pushed
the
ryan/wasm-headers
branch
2 times, most recently
from
October 25, 2026 15:32
cfe027b to
4f23727
Compare
size_t, intptr_t and ptrdiff_t are long and unsigned long on wasm32, since _Addr is long, but the generic bits/stdint.h gives their limits the types of int32_t and uint32_t. An expression that mixes them, such as systemd's CONST_MIN((size_t)INT_MAX, SIZE_MAX / 4), then fails to compile because the operand types differ. Define the limits as long constants, as clang's own __SIZE_MAX__ and friends are. Ported from ryanrasti/tombl-musl@658e061c.
Add the numbers that the kernel's asm-generic/unistd.h has gained since the table was generated, such as fchmodat2, setxattrat, removexattrat and open_tree_attr, which systemd calls by number. Cherry-picked from ryanrasti/tombl-musl@5c158631.
__NR_syscalls was still 451 after numbers up to 471 were added, so it no longer covered the table. It is 472 in the kernel's asm-generic/unistd.h. Also add map_shadow_stack (453), which the other arches' tables carry and which arm64 and RISC-V now implement as well as x86. The wasm kernel answers it with ENOSYS.
tombl
force-pushed
the
ryan/wasm-headers
branch
from
October 25, 2026 15:58
4f23727 to
5f2efaa
Compare
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.
Both changes are wasm32 port fixes in
arch/wasm32._Addrislongon wasm32, matching clang's wasm32 ABI, wheresize_tisunsigned long; wasm32 is the only 32-bit musl arch with_Addr long. The genericbits/stdint.hgives 32-bitlongtargetsINT32_*/UINT32_MAX, which haveint's types, soSIZE_MAXwasunsigned int. Expressions that check their operands' types failed to compile, for example systemd'sCONST_MIN((size_t)INT_MAX, SIZE_MAX / 4). The fix is an arch override,arch/wasm32/bits/stdint.h.asm-generic/unistd.h, which has all of them. Upstream musl adds new numbers per arch the same way. Note one behaviour change: withSYS_fchmodat2defined,fchmodat()with any nonzero flags (AT_SYMLINK_NOFOLLOW,AT_EMPTY_PATH) now tries the kernel'sfchmodat2first. OnlyENOSYSfalls back to the old path, and other errors propagate. Zero flags still usefchmodat.map_shadow_stack(a separate commit by Tom, after review).__NR_syscallswas still 451, below the new numbers. It is now 472, matching the kernel.map_shadow_stack(453) is added, as upstream musl's other arch tables have it, and arm64 and RISC-V implement it as well as x86. The wasm kernel returnsENOSYS.Test (basic-init
stdint-limits, in distro#206):_Static_asserts that each limit has its type's type. Before (main's pins), it fails to compile with six errors, for example__builtin_types_compatible_p(unsigned int, unsigned long): SIZE_MAX is not a size_t. After: pass.The first two commits are byte-identical diffs of Ryan Rasti's ryanrasti/tombl-musl@658e061c and @5c158631. The syscall commit was re-picked after review, because the previous version had moved two entries. So he remains their author, and only the messages were rewritten. The third commit is Tom's.