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

Wasmtime Windows static linking fails #65

Open
ashtonmeuser opened this issue Mar 7, 2024 · 0 comments
Open

Wasmtime Windows static linking fails #65

ashtonmeuser opened this issue Mar 7, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@ashtonmeuser
Copy link
Owner

ashtonmeuser commented Mar 7, 2024

Building Godot Wasm with the Wasmtime runtime enabled (wasm_runtime=wasmtime) fails to compile.

Firstly, the addon only builds on Windows with Wasmtime enabled because it is dynamically linking the Wasmtime DLL. Adding the C++ defines WASM_API_EXTERN and WASI_API_EXTERN prevents dynamic linking as recommended in wasmtime#7808. This is because the Wasmtime wasm.h does not include checks for LIBWASM_STATIC as implemented in wasm-c-api#183.

When the defines are provided, build fails with the following (truncated) errors.

wasmtime\include\wasm.h(96): error C2059: syntax error: 'constant'
wasmtime\include\wasm.h(110): error C3861: 'wasm_byte_vec_new': identifier not found
wasmtime\include\wasm.h(116): error C3861: 'wasm_byte_vec_new': identifier not found
wasmtime\include\wasm.h(125): error C2059: syntax error: 'constant'
wasmtime\include\wasm.h(127): error C2059: syntax error: 'constant'
wasmtime\include\wasm.h(134): error C2059: syntax error: 'constant'

A WIP branch was created to debug. I thought this could be a #define macro conflict so added a GODOT_WASM_ prefix to all macros. Still could be a macro conflict with Godot C++ library and Wasmtime. See this GHA run for failure example.

It's possible to get Wasmtime working with Windows by modifying the addons/godot-wasm/godot-wasm.gdextension file to include wasmtime.dll as a dependency and including wasmtime.dll in the addons directory. An example of such a workaround can be seen here with the following context provided.

Compiling with the Wasmtime runtime on Windows is failing static linking as of Godot Wasm v0.3.4. In addition to the built Godot Wasm binaries, you'll need to copy wasmtime.dll to GODOT_DOOM_DIR/addons/godot-wasm/bin/windows and to update godot-wasm.gdextension to include the Wasmtime DLL as a dependency. Refer to the addons directory of the project source.

Ideally, building with the Wasmtime runtime would produce a single Windows binary similar to what's being done for Wasmer.

@ashtonmeuser ashtonmeuser added the help wanted Extra attention is needed label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant