luau-lang / luau

A fast, small, safe, gradually typed embeddable scripting language derived from Lua
https://luau-lang.org
MIT License
3.8k stars 352 forks source link

emscripten build failure #1199

Closed cppmadguy closed 3 months ago

cppmadguy commented 3 months ago

Luau version = 0.616 Emscripten version = 3.1.56 Underlying c++ compiler = clang version 19.0.0git (https:/github.com/llvm/llvm-project 1d900e298449d43547312364751f730b7a0d07d1)

I added Luau to my CMakeLists.txt (depending only on Luau.VM since I want to precompile Luau scripts in advance and small javascript/wasm files) and use the following command to generate my build directory: emcmake cmake . -B build-web -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1

I then compile using make -C build-web

And it fails when compiling CodeAllocator.cpp with this message: fatal error: error in backend: llvm.clear_cache is not supported on wasm

I think the issue is line 108 because it calls __builtin___clear_cache()

A simple fix would be to add some ifdefs around this call, but I don't know why it is necessary in the first place. Is emscripten a supported target ? I don't need to enable codegen on wasm ( I believe the Luau interpreter is fast enough for my needs, even when running interpreted on the web ) so an indication on how to disable codegen entirely would fix my issue.

vegorov-rbx commented 3 months ago

depending only on Luau.VM

There's probably some mistake you made in this part, as CodeAllocator.cppis a part of Luau.CodeGen and Luau.VM doesn't depend on that.

vegorov-rbx commented 3 months ago

We have a Web build in CMakeLists.txt that uses Emscripten and you can even try it out here https://luau-lang.org/demo

cppmadguy commented 3 months ago

shame on me, I didn't specify which target to build, so all targets were built no matter the dependencies. thanks for your precious time anyway !