Skip to content

Conversation

@The-King-of-Toasters
Copy link
Contributor

Reloaded version of #21440 post writergate. Original description below:


Changes by Arnd Bergmann have migrated all supported architectures to use a table for their syscall lists. This removes the need of calling a C pre-processor and simplifies the logic dramatically.
The side effect is the number of names changed on targets that use the "generic" table. That list (located under scripts/syscall.tbl) adds the _time64 suffix to syscalls taking a timespec64 on 32-bit targets. Similarly, the _time32 suffix has been removed.

The result is a lot of breakage in our Linux wrappers, which makes me worried that the logic for determining the proper timespec to use was subtly broken all this time. Should be a good chance to finish #4726 - we only have 14 12 years after all...

CC @alexrp if things break.

@alexrp alexrp self-assigned this Aug 5, 2025
@The-King-of-Toasters
Copy link
Contributor Author

The-King-of-Toasters commented Aug 7, 2025

I've modified the tool again to consolidate all the logic into one table and restored the order of the emitted variables for easier diffing. This should fix the x32 syscall abi problems that @rootbeer pointed out.

@The-King-of-Toasters The-King-of-Toasters force-pushed the syscall-tables branch 2 times, most recently from 29ee317 to 89a1d94 Compare August 7, 2025 08:11
Copy link
Contributor

@rootbeer rootbeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code all looks great, one more suggestion for the x32 ABI though! Again, not a regression but its soooo close now ...

Copy link
Contributor

@rootbeer rootbeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor comments after looking this over again. The core of the change looks great, and the code seems much simpler now.

@The-King-of-Toasters The-King-of-Toasters force-pushed the syscall-tables branch 2 times, most recently from f707ada to 7f49b6c Compare August 8, 2025 09:31
@alexrp
Copy link
Member

alexrp commented Aug 9, 2025

Failures look to be #24754.

@The-King-of-Toasters
Copy link
Contributor Author

Fixing the merge conflict, but FYI the CI is all green.

Copy link
Contributor

@rootbeer rootbeer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I just noticed while looking at this again. Not something to hold up any merges for.

Changes by Arnd Bergmann have migrated all supported architectures to
use a table for their syscall lists. This removes the need to use the
C pre-processor and simplifies the logic considerably.

All currently supported architectures have been added, with the ones Zig
doesn't support being commented out. Speaking of; OpenRisc has been
enabled for generation.
The generic syscall table has different names for syscalls that take a
timespec64 on 32-bit targets, in that it adds the `_time64` suffix.
Similarly, the `_time32` suffix has been removed.

I'm not sure if the existing logic for determining the proper timespec
struct to use was subtly broken, but it should be a good chance to
finish ziglang#4726 - we only have 12 years after all...

As for the changes since 6.11..6.16:

6.11:
 - x86_64 gets `uretprobe`, a syscall to speed up returning BPF probes.
 - Hexagon gets `clone3`, but don't be fooled: it just returns ENOSYS.
6.13:
 - The `*xattr` family of syscalls have been enhanced with new `*xattrat`
   versions, similar to the other file-based `at` calls.
6.15:
 - Atomically create a detached mount tree and set mount options on it.

Finally, this commit also adds the syscall numbers for OpenRISC and maps
it to the `or1k` cpu.
Newer 32-bit Linux targets like 32-bit RISC-V only use the 64-bit
time ABI, with these syscalls having `time64` as their suffix.

This is a stopgap solution in favor of a full audit of `std.os.linux` to
prepare for ziglang#4726.

See also ziglang#21440 for prior art.
@The-King-of-Toasters
Copy link
Contributor Author

Any more changes needed or does it lgtm?

@alexrp
Copy link
Member

alexrp commented Aug 15, 2025

Looks good, thanks!

@alexrp alexrp merged commit 47e6528 into ziglang:master Aug 15, 2025
14 checks passed
@alexrp alexrp self-requested a review August 15, 2025 05:45
@alexrp alexrp removed their assignment Aug 15, 2025
@alexrp alexrp removed their request for review August 15, 2025 05:45
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.

3 participants