-
Notifications
You must be signed in to change notification settings - Fork 117
Unable to compile to wasm #132
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
Comments
rlua uses libc because it uses PUC Rio Lua underneath, which is a C library that also uses libc. I don't think you can compile PUC Lua to wasm directly either, but if you can find a reasonable way I can remove the libc dependency in rlua once enough of the allocators features are stable. |
Which features of libc are used that rlua needs? Only memory allocation? For the purposes I'm currently using rlua, it'd be perfectly ok to allocate a fixed block of memory to Lua until a real fix is found... |
I really don't know the current situation w.r.t. libc and wasm32-unknown-unknown (which I'm assuming you're using). If you remove the libc dependency from rlua, PUC-Lua itself will still use libc's malloc and free (and tons of other stuff from libc too), so I'm not sure what good it will do to remove the libc dependency from rlua without solving the rest of it. Can you build PUC-Lua for wasm right now at all? I think you might be able to with emscripten, but I'm really not sure. This is getting more in-depth into wasm build infrastructure than I'm really familiar with, but this problem that you're running into is probably the first of many. Certainly getting the "rlua" part working is vastly easier than getting the "actual PUC-Rio Lua library" part working. I guess the libc crate on wasm32-unknown-unknown targets is empty, which is the immediate cause of this bug, but certainly you'd run into problems after this trying to link the PUC-Lua static library? I think in order to get this to work you'd need to compile rlua in an emscripten environment.. but then I suppose you can set the rust target to "wasm32-unknown-emscripten" and this problem would go away anyway? |
Thanks for the quick reply! I haven't tried wasm32-unknown-emscripten yet, using wasm32-unknown-unknown right now as you said. Considering all the complications you've mentioned, it probably doesn't make sense to fix this right now. |
Do you mean the only reason you’re using libc is for the allocators?
I know there exists a lua port to javascript via emscripten, there must be a way...
|
Emscripten's pipeline is long. It gives you a ton of stuff that doesn't exist in WASI solves some of this. The So, eventually, this will likely Just Work for WASI targets but not yet. |
I think it takes long for exception support in wasi, is it possible to take prebuilt I'm not sure if it possible to link |
@clouds56 It's possible. Rust's |
what about https://github.com/WebAssembly/wasi-libc |
I'm very interested in having rlua running in wasm but don't currently have time to look into it. I'd be very welcoming of any work towards it if anyone wants to have a crack at it. :-) |
rlua is going to be deprecated soon and this feature is already supported by mlua (wasm32 emscripten target) |
Trying to build the project using "cargo web build" (which targets wasm32-unknown-unknown) I get the following error:
error[E0425]: cannot find function
free
in modulelibc
--> src/lua.rs:387:19
|
387 | libc::free(ptr as *mut libc::c_void);
| ^^^^ not found in
libc
error[E0412]: cannot find type
c_void
in modulelibc
--> src/lua.rs:387:42
|
387 | libc::free(ptr as *mut libc::c_void);
| ^^^^^^ not found in
libc
help: possible candidates are found in other modules, you can import them into scope
|
1 | use core::ffi::c_void;
|
1 | use std::ffi::c_void;
|
1 | use std::os::raw::c_void;
The text was updated successfully, but these errors were encountered: