Proof of concept: Emscripten build for Luau and Lua 5.x #95
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.
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
andemCompileStep
.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.