zig icon indicating copy to clipboard operation
zig copied to clipboard

Default std.posix.system.ucontext_t is void

Open rootbeer opened this issue 1 year ago • 0 comments

PR https://github.com/ziglang/zig/pull/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

rootbeer avatar Jul 22 '24 04:07 rootbeer