json-c icon indicating copy to clipboard operation
json-c copied to clipboard

Add support for WASI

Open fredldotme opened this issue 2 years ago • 5 comments

Disables shared libraries for WASI only and makes sure compat doesn't redefine builtins.

fredldotme avatar Sep 02 '23 13:09 fredldotme

Sidenote: I haven't checked whether json_c_snprintf is actually used anywhere, actually. But I made it a possibly unused function due to the assumption that, just because it's not used in one source file might not mean much.

fredldotme avatar Sep 02 '23 13:09 fredldotme

I haven't read more than the first few lines of the diff, but already I can tell you I'm not going to merge this. Please don't litter the code with ifdef __wasi__ lines. Instead, figure out why the regular symbol/feature detection isn't working, and fix that.

hawicz avatar Sep 03 '23 16:09 hawicz

Is at least the CMake part kosher enough or are there complaints about that approach too?

fredldotme avatar Sep 03 '23 16:09 fredldotme

Sure, I guess that's ok, though it's not clear to me why you're disabling shared libs and tests, so a comment explaining that would be nice.

Also, is "WASI" in this case "Web Assembly System Interface"? Please at least mention that full name in the commit message, and ideally add a "Building on WASI" section to README.md (assuming there are some special steps needed beyond the Building on Unix section)

Finally, the duplication in snprintf_compat.h is bugging me. Can you try to consolidate with the MSC/MINGW case, perhaps with a #define _vsnprintf vsnprintf for the __wasi__ case? (does WASI really have the same lack-of-termination bug? argh!)

hawicz avatar Sep 03 '23 17:09 hawicz

Sure can add some more commentary.

Yes WASI is "WebAssembly System Interface", and it has no concept of shared libraries at the moment, so everything must be statically linked together.

I'll take a look at the compat parts in a bit.

fredldotme avatar Sep 03 '23 17:09 fredldotme