mlua icon indicating copy to clipboard operation
mlua copied to clipboard

Error compiling module to wasm32-unknown-emscripten

Open scottroot opened this issue 1 year ago • 0 comments

Hi, I am trying to compile my lib to wasm32-unknown-emscripten and it throws an error if I use feature "module". Is this expected to work currently?

The rust code and config.toml is copied from the module example.

Makefile's build: cargo build --target wasm32-unknown-emscripten --release --features lua53

Cargo.toml

 [package]
name = "rust_module"
version = "0.0.0"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[workspace]

[features]
lua54 = ["mlua/lua54"]
lua53 = ["mlua/lua53"]
lua52 = ["mlua/lua52"]
lua51 = ["mlua/lua51"]
luajit = ["mlua/luajit"]

[dependencies]
mlua = { version = "0.9.7", features = ["module"]}

[profile.release-with-debug]
inherits = "release"
debug = true

Running everything in Docker Ubuntu container.

Error: error: linking with emcc failed: exit status: 1

  • wasm-ld: error: /src/smallcrate/target/wasm32-unknown-emscripten/release/deps/small_crate.small_crate.38fb851be9ce66e8-cgu.0.rcgu.o: undefined symbol: lua_pushinteger
  • Same error with different symbols (some repeated):
  • lua_settop
  • lua_pushinteger
  • lua_gettop
  • lua_setmetatable
  • lua_error
  • lua_checkstack
  • luaL_traceback
  • lua_settop
  • lua_setmetatable
  • lua_error
  • lua_getallocf
  • lua_pushlstring
  • lua_gettop
  • lua_checkstack
  • lua_settop
  • lua_pushinteger
  • lua_settop
  • lua_getmetatable
  • lua_settop

What am I missing with this step? I am able to compile to wasm32-unknown-emscripten when not using feature module, but I need to compile a module that can be imported into lua running in wasm.

scottroot avatar May 10 '24 02:05 scottroot