Skip to content

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.

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