mlua-rs / luau-src-rs

Source code and logic to build Roblox Luau for Rust
Other
7 stars 4 forks source link

Luau compilation fails with the wasm32-unknown-emscripten target on Windows. #2

Open DynamicField opened 4 weeks ago

DynamicField commented 4 weeks ago

When compiling mlua with the luau feature using cargo build -target wasm32-unknown-emscripten on a Windows machine, an error occurs where the compiler believes that /std:c++17 is a path to a compiled file:

warning: mlua-sys@0.6.0: em++: error: /std:c++17: No such file or directory ("/std:c++17" was expected to be an input file, based on the commandline arguments provided)

error: failed to run custom build command for `mlua-sys v0.6.0`
[...]

error occurred: Command "cmd" "/c" "em++.bat" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-emscripten" "-I" "C:\\Users\\jeuxj\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\luau0-src-0.9.1+luau625\\luau\\Ast\\include" "-I" "C:\\Users\\jeuxj\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\luau0-src-0.9.1+luau625\\luau\\Common\\include" "-std=c++17" "/std:c++17" "-fexceptions" "-fno-math-errno" "-DLUAI_MAXCSTACK=1000000" "-DLUA_VECTOR_SIZE=3" "-DNDEBUG" "-o" "C:\\Users\\jeuxj\\FastDev\\Proj\\target\\wasm32-unknown-emscripten\\release\\build\\mlua-sys-7b31f19e5a5927e4\\out\\luau-build\\lib\\9bb9ba4c8bd32a76-Ast.o" "-c" "C:\\Users\\jeuxj\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\luau0-src-0.9.1+luau625\\luau\\Ast\\src\\Ast.cpp" with args cmd did not execute successfully (status code exit code: 1).

This likely due to both -std=c++17 and /std:c++17 arguments being specified, which causes the compiler to be weirdly confused (see https://github.com/mlua-rs/luau-src-rs/blob/main/src/lib.rs#L116-L117)

khvzak commented 4 weeks ago

This likely due to both -std=c++17 and /std:c++17 arguments being specified, which causes the compiler to be weirdly confused (see https://github.com/mlua-rs/luau-src-rs/blob/main/src/lib.rs#L116-L117)

flag_if_supported is generally a safe way to enable only one option supported by compiler. Seems the issue here is with cc crate (what version do you use? can you try latest?)

mlua is tested on windows with luau (see ci job) and this code does not cause any issues yet.

DynamicField commented 1 week ago

Upgrading the cc crate to the latest version in build-dependencies (1.0.100) doesn't change anything unfortunately.

The CI job you linked builds on Windows for Windows... but I'm building on Windows for wasm32-unknown-emscripten. The only CI job that builds for wasm32-unknown-emscripten is ran on Ubuntu.