Repository navigation
Prevent stderr being linked when in-memory stdio is used - #912
jeremy-code wants to merge 1 commit into
Conversation
5810ee8 to
3213b8f
Compare
__stderr_FILE references the addresses of __stdio_write, __stdio_seek, __stdio_close; hence, linking stderr will include those imports. floating_point_not_supported and long_double_not_supported now only outputs to stderr if it has already been linked instead of referencing stderr directly. Otherwise, it traps silently. Add __stdio_write_needs_stderr function to reference __stderr_FILE.
3213b8f to
12e1c2e
Compare
alexcrichton
left a comment
There was a problem hiding this comment.
Thanks for the PR here, but I can't help but think that this is a bit of a roundabout way to solve a problem that's self-inflicted by wasi-libc. Thinking about this I'm wondering if it might be better to just return an error on unsupported format identifiers instead of trying to print anything to the screen.
For example this PR has pretty surprising behavior IMO where the rough intention is to print an error, but such an error only happens to show up should you use some other functions. That sort of behavior feels like spooky-action-at-a-distance to me and best avoided. If an error is unconditionally returned it's still surprising but at least it's deterministic.
Would you be interested to try to sketch out a solution like that?
__stderr_FILEreferences the addresses of__stdio_write,__stdio_seek,__stdio_close; hence, linkingstderrwill include those imports.floating_point_not_supportedandlong_double_not_supportednow only output tostderrif it has already been linked instead of referencingstderrdirectly. Otherwise, it traps silently.Add
__stdio_write_needs_stderrfunction that references__stderr_FILE.Closes wasi-sdk#666.