-
Notifications
You must be signed in to change notification settings - Fork 837
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
Request: Add Lua Language Support to Wasmer #5335
Comments
Thanks for opening the issue. It seems the first step would be to compile Lua to Wasm/WASIX and then use Wasmer for that. Lua community could probably help on this as well (compiling Lua to WASIX), but we would be more than keen to help you on that if you encounter any issues |
To ensure I understand correctly: Does Wasmer load WebAssembly (Wasm) files? If so, do I just need to make sure I compile Lua properly into the Wasm or WASIX format? I'm new to WebAssembly and exploring it—it's such an interesting technology! |
Hello @JustKira! Yes, Wasmer is a Wasm runtime. It can thus "understand" Wasm files, in the sense that it can load and run them. Therefore yes, in principle, you should just make your Lua code compile to Wasm to be able to run them in Wasmer. In practice, however, and depending on what your program does, it might not be so simple. If your program needs to interact with the filesystem, create sockets or shows other specific behaviours - you can sort of think OS calls - in order to have a Wasm file (in jargon, a module) that you can use with any runtime, one needs:
WASI and its extension WASIX are specifications of the standard API, which Wasmer implements. The next step, therefore, would be 2a or 2b: this is the endeavour where the Lua community could help on. After a quick search online, it seems that there are unmaintained Lua-to-Wasm compilers (1, 2) and maintained Lua-to-Wasm compilers that don't compile to WASI (3); for (2b), one could try to compile Lua interpreters in a language that can target Wasm to it; an example of this mechanism can be seen in our efforts for php. |
To expand on @xdoardo's answer: The official lua interpreter seems to be written exclusively in C. Getting it working in WASIX should be relatively simple. The steps involved would be:
You can take a look at the build setup we have for PHP to see how it's done; TLDR:
and then you let it run normally. I'm not super-familiar with lua, so I don't know if it does any sort of JIT'ing; if it does, that needs to be disabled as dynamic code loading is not supported in WASM (yet). |
Thanks for proposing a new feature!
Motivation
The motivation behind this request stems from my ongoing project to build a custom game engine where the core is developed in Rust, and the UI layer is implemented in Lua alongside my custom language. The idea is to allow developers to contribute to the engine using different languages, enabling the creation of specific features in their preferred language while maintaining seamless integration within the same engine.
Wasmer appears to be the ideal foundation for this project due to its support for multiple languages. However, Lua—an essential component of my project—is currently not supported. This feature would fill a critical gap in Wasmer’s otherwise robust language support and make it an even more versatile runtime.
Proposed solution
Add support for the Lua language in Wasmer. This feature would allow developers to compile Lua code to WebAssembly and execute it via Wasmer, similar to the existing support for other languages. Ideally, this could include:
A Lua-to-WASM compiler or integration with existing compilers.
Runtime compatibility with Lua-specific features, such as its lightweight nature and efficient scripting capabilities.
Alternatives
I’ve explored existing Lua-WASM and Lua-Rust interpreters, but they don't fully meet the needs of this project, particularly when it comes to the ability to seamlessly integrate multiple languages within a single engine runtime. By integrating Lua support directly into Wasmer, the ecosystem gains flexibility and scalability, aligning with Wasmer's goal of being a universal WebAssembly runtime.
Additional context
This feature would open doors for projects that require multi-language integration, particularly in game engines, scripting, or similar domains. Lua’s lightweight design and widespread use make it a strong candidate for inclusion in Wasmer’s supported languages.
For reference, there was a related issue (#2612) that was previously closed without a solution. Given the importance of Lua for projects like mine, I believe this deserves reconsideration.
The text was updated successfully, but these errors were encountered: