You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Testing the wasm32-unknown-emscripten target fails due to a filename mismatch in the compilation output:
$ cross test --verbose --target wasm32-unknown-emscripten
+ "rustup" "target" "list"
+ "cargo" "fetch" "--manifest-path" "/home/adam/dev/ldcore/Cargo.toml"
+ "rustc" "--print" "sysroot"
+ "docker" "run" "--userns" "host" "--rm" "--user" "1000:1000" "-e" "CARGO_HOME=/cargo" "-e" "CARGO_TARGET_DIR=/target" "-e" "USER=adam" "-e" "XARGO_HOME=/xargo" "-v" "/home/adam/.xargo:/xargo" "-v" "/home/adam/.cargo:/cargo" "-v" "/home/adam/dev/ldcore:/project:ro" "-v" "/home/adam/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu:/rust:ro" "-v" "/home/adam/dev/ldcore/target:/target" "-w" "/project" "-it" "japaric/wasm32-unknown-emscripten:v0.1.14" "sh" "-c" "PATH=$PATH:/rust/bin \"cargo\" \"test\" \"--verbose\" \"--target\" \"wasm32-unknown-emscripten\""
Compiling ldcore v0.1.0 (/project)
Running `rustc --edition=2018 --crate-name ldcore src/lib.rs --color always --emit=dep-info,link -C debuginfo=2 --test -C metadata=ecd9c7299ab7d7c3 -C extra-filename=-ecd9c7299ab7d7c3 --out-dir /target/wasm32-unknown-emscripten/debug/deps --target wasm32-unknown-emscripten -C incremental=/target/wasm32-unknown-emscripten/debug/incremental -L dependency=/target/wasm32-unknown-emscripten/debug/deps -L dependency=/target/debug/deps`
Finished dev [unoptimized + debuginfo] target(s) in 5.63s
Running `node-wasm /target/wasm32-unknown-emscripten/debug/deps/ldcore-ecd9c7299ab7d7c3.js`
running 1 test
test tests::it_works ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running `node-wasm /target/wasm32-unknown-emscripten/debug/deps/ldcore_ecd9c7299ab7d7c3.wasm`
module.js:487
throw err;
^
Error: Cannot find module '/target/wasm32-unknown-emscripten/debug/deps/ldcore_ecd9c7299ab7d7c3.wasm'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Function.Module.runMain (module.js:605:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:575:3
error: test failed, to rerun pass '--lib'
I checked the output directory and confirmed the file does not exist, but one named ldcore-ecd9c7299ab7d7c3.wasm does (note the hyphen instead of the underscore):
Install cross: cargo install cross (make sure you also have Docker installed and available)
I had to modify the container image that cross uses to run WASM so it would have a newer version of emsdk. This is needed for it to work properly, but it is not fixed upstream yet.
Create a library project from the template: cargo new --lib foo && cd foo
Build the tests using cross or cargo (either one will reproduce the error): cargo build --tests --target wasm32-unknown-emscripten
Attempt to run the the tests: cross test --target wasm32-unknown-emscripten
Possible Solution(s)
I did some digging, and to my surprise, this is probably caused by a specific case implemented just for WASM: the should_replace_hyphens field. Some more research needs to be done to figure out exactly why this was added and if it is still required by some supported configurations. There may have been some update to the Emscripten SDK that made it start emitting hyphens - in that case, I'm not entirely sure how we will detect and fix that.
Notes
Output of cargo version: cargo 1.38.0-nightly (e853aa976 2019-08-09) (having trouble updating to latest nightly, but will edit this when I've reproduced it.
Emscripten SDK version: 1.38.31 (latest as of the time of posting)
The text was updated successfully, but these errors were encountered:
After thinking about it further, I'm skeptical that Cargo should even be trying to run the WASM file. It already runs the JS file which appears to be a wrapper around the WASM.
Mark Emscripten's .wasm files auxiliary
This fixes#7471 and fixes#7255 by preventing the .wasm file from
being treated as an executable binary, so `cargo test` and `cargo run`
will no longer try to execute it directly. This change is only made
for Emscripten, which outputs a .js file as the primary executable
entry point, as opposed to other WebAssembly targets for which the
.wasm file is the only output.
Problem
Testing the
wasm32-unknown-emscripten
target fails due to a filename mismatch in the compilation output:I checked the output directory and confirmed the file does not exist, but one named
ldcore-ecd9c7299ab7d7c3.wasm
does (note the hyphen instead of the underscore):I've confirmed that building the project outside of the
cross
environment produces the same file with a hyphen, not an underscore:Steps (Linux)
cargo install cross
(make sure you also have Docker installed and available)cargo new --lib foo && cd foo
cargo build --tests --target wasm32-unknown-emscripten
cross test --target wasm32-unknown-emscripten
Possible Solution(s)
I did some digging, and to my surprise, this is probably caused by a specific case implemented just for WASM: the
should_replace_hyphens
field. Some more research needs to be done to figure out exactly why this was added and if it is still required by some supported configurations. There may have been some update to the Emscripten SDK that made it start emitting hyphens - in that case, I'm not entirely sure how we will detect and fix that.Notes
cargo version
:cargo 1.38.0-nightly (e853aa976 2019-08-09)
(having trouble updating to latest nightly, but will edit this when I've reproduced it.The text was updated successfully, but these errors were encountered: