Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how this fixes your problem, but I don't think
msync
existence should logically depend onucontext_t
existence.I believe the approach going forward is supposed to be something more direct, like:
But that won't work here (yet?) because posix.zig unilaterally defines an
msync
.... So you can either fix posix.zig to make thatmsync
void when the underlyingsystem.msync
is missing, or just check for@TypeOf(posix.system.msync) != void
in debug.zig, and then make sure the defaultsystem
in posix.zig has a{}
msync
entry (see #20728 where I fixed a similar issue with freestanding use of debug.zig).OTOH, the
isValidMemory
function in debug.zig that your backtrace goes through starts with:Your native_os is "other", so maybe you can add "other" to this list here. Or, change your target to "freestanding"? (I'm not sure what the difference between "other" and "freestanding" targets is meant to be, so I'm not sure which of those might be the right suggestion.)
Overall, it seems worthwhile to make debug.zig a good example of how to do feature detection "correctly" in Zig, so cleaning it up to have a simple
const have_msync = @TypeOf(posix.system.msync) != void
(and fixing posix.zig to export msync symbols cleanly) is the right way to go, but I'm definitely not an authoritative source of such opinions.EDIT: Added missing
@TypeOf()
on msync checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intention with the
other
OS is that you can do the whole "bring your own OS" thing. See #3784. This is distinct fromfreestanding
which is an environment where there explicitly is no OS.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestions here were not quite as straightforward as I made it seem... I've put together a change at #20845. This should solve your specific problem (getting
isValidMemory
to compile on theother
target OS), and I think it does so in the right way, and it includes a test too. But we'll have to wait and see if the Zig core folks think its good...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rootbeer #20845 fixes my issue and is definitely a higher quality fix than mine. Closing this PR