You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
std.debug.StackIterator in embedded throws compile error for ucontext_t being missing in std.posix.system #20710
with zig build-exe -target native-freestanding main.zig.
The debug.zig module imports std.posix, but tries to detect which bits of posix are present or not. The compile is failing on the line meant to do the detection:
pubconsthave_ucontext=posix.ucontext_t!=void;
In std.posix ucontext_t is defined via pub const ucontext_t = system.ucontext_t;, and system is from:
But it seems awkward for the default system to declare all the things it doesn't support? (Presumably there is a long list of other identifiers to void out like this.)
Alternatively, the std.debug code could switch back to using @hasDecl for feature detection. Or, the std.debug code could reduce its Posix dependency or move the Posix-dependent parts out to somewhere else?
Also, seems like there should be tests against freestanding targets for the parts of debug that should work with them.
I'll assume the patch I suggested above is the best idea for now (and will put a PR together for that), but if anyone with more of a clue has other ideas let me know.
Activity
rootbeer commentedon Jul 21, 2024
Reproduced by compiling:
with
zig build-exe -target native-freestanding main.zig.The debug.zig module imports std.posix, but tries to detect which bits of posix are present or not. The compile is failing on the line meant to do the detection:
In std.posix
ucontext_tis defined viapub const ucontext_t = system.ucontext_t;, andsystemis from:The empty struct there has no
ucontext_t. So this problem would impact any compile without a libc, for platforms other than Linux and Plan9, I think?One fix is to add a
voiducontext_tinto the defaultsystemobject:But it seems awkward for the default
systemto declare all the things it doesn't support? (Presumably there is a long list of other identifiers to void out like this.)Alternatively, the std.debug code could switch back to using
@hasDeclfor feature detection. Or, the std.debug code could reduce its Posix dependency or move the Posix-dependent parts out to somewhere else?Also, seems like there should be tests against freestanding targets for the parts of debug that should work with them.
I'll assume the patch I suggested above is the best idea for now (and will put a PR together for that), but if anyone with more of a clue has other ideas let me know.
Default std.posix.system.ucontext_t is void
Default std.posix.system.ucontext_t is void
Default std.posix.system.ucontext_t is void