Proof of concept: Emscripten build for Luau and Lua 5.x
This is more of a FYI / potential resource for others than it is a real PR: the code is messy, has a few chunks lifted from sokol-zig, and a couple of the examples have been switched to c_allocator to dodge Emscripten's allergy to the page allocator . If you just close the PR I won't take offense. :)
Anyway, I'm trying to integrate Luau into a project based on sokol-zig, and while that's not all wired up yet, I do have the interpreter example running in the browser (using Emscripten's atrocious stdin UX). The main issue appeared to be getting both compilation and linking for C++ code to refer to the same versions of the C++ libs, STL, etc. The only way I could really get this to work was to take sokol-zig's linker step (and a bunch of the surrounding emsdk setup code), and add another helper to do compilation as well.
Also had to make sure that the example never invokes the page allocator, directly or otherwise, since that's an instant crash with Emscripten.
To the extent that any bits are interesting, those are probably buildLuauEmscripten and emCompileStep.
I've gone ahead and gotten Lua 5.x to build w/ Emscripten as well. Unsure why it was necessary to include a stub stdio.h ... but no stub for any other system header was required.
I did try to build Lua 5.x without using emcc to compile - just using it for the linking step - but that triggers the longjmp issues.
Thank you for looking into this! I am not super familiar with Emscripten but this does seem worthwhile. I don't have time right now to take a closer look, but feel free to keep working on this and ping me if you ever get things working!
Related to PR #86