Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept: Emscripten build for Luau and Lua 5.x #95

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

luchak
Copy link
Contributor

@luchak luchak commented Sep 16, 2024

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.

@luchak luchak changed the title Proof of concept: Emscripten build for Luau Proof of concept: Emscripten build for Luau and Lua 5.x Sep 17, 2024
@luchak
Copy link
Contributor Author

luchak commented Sep 18, 2024

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.

@natecraddock
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants