Skip to content

Default std.posix.system.ucontext_t is void #20728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

rootbeer
Copy link
Contributor

PR #20679 ("std.c reorganization") switched feature-detection code to use T != void checks in place of @hasDecl. However, the default std.posix.system struct (used by freestanding targets) is empty, so compile-time feature detection against symbols in there (specifically std.posix.system.ucontext_t in this case), fail at compile time.

This PR adds a void ucontext_t into the std.posix.system default. While I'm confident this fixes the particular problem, it may not be the right approach (it seems like this struct will eventually have to be padded out with a lot of void symbols). I'm not sure if deeper fixes to std.debug are in order, or something else entirely.

This PR also adds pseudo-"freestanding" variation of the existing StackIterator "unwind" test. The new test is somewhat hacky (its freestanding, but assumes it can invoke a Linux exit syscall), but it does detect this problem.

Fixes #20710

PR ziglang#20679 ("std.c reorganization")
switched feature-detection code to use "T != void" checks in place of
"@hasDecl".  However, the std.posix.system struct is empty, so
compile-time feature detection against symbols in there (specifically
`std.posix.system.ucontext_t` in this case), fail at compile time on
freestanding targets.

This PR adds a void ucontext_t into the std.posix.system default.

This PR also adds pseudo-"freestanding" variation of the StackIterator
"unwind" test.  It is sort of hacky (its freestanding, but assumes it can
invoke a Linux exit syscall), but it does detect this problem.

Fixes ziglang#20710
@rootbeer rootbeer force-pushed the 20710-stackiterator-ucontext branch from 03f92f5 to 049039c Compare July 22, 2024 15:20
@andrewrk
Copy link
Member

Nice work on the test.

@andrewrk andrewrk merged commit e8503ec into ziglang:master Jul 23, 2024
10 checks passed
@rootbeer rootbeer deleted the 20710-stackiterator-ucontext branch July 23, 2024 20:13
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.

std.debug.StackIterator in embedded throws compile error for ucontext_t being missing in std.posix.system
2 participants