Closed
Description
When libstd is built with codegen-units > 1, programs built for wasm32-unknown-emscripten can crash.
I tried this code:
hello.rs
fn main() {
println!("Hello, WebAssembly!");
}
rustc --target wasm32-unknown-emscripten hello.rs
node hello.js
I expected to see this happen:
Hello, WebAssembly!
Instead, this happened:
exception thrown: RuntimeError: invalid function,RuntimeError: invalid function
at (<WASM>[804]+7)
at Object.Module.dynCall_vii (~/tlively/hello.js:5928:92)
at invoke_vii (~/tlively/hello.js:6022:26)
at (<WASM>[550]+121)
at (<WASM>[804]+7)
at Object.Module.dynCall_vii (~/tlively/hello.js:5928:92)
at invoke_vii (~/tlively/hello.js:6022:26)
at (<WASM>[256]+130)
at (<WASM>[114]+50)
at (<WASM>[50]+7)
failed to asynchronously prepare wasm: RuntimeError: invalid function
(node:151136) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RuntimeError: invalid function
(node:151136) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
However, compiling libstd with codegen-units = 1
gives the expected behavior.
Meta
rustc:
rustc 1.20.0-dev (3610a70ce 2017-07-05)
binary: rustc
commit-hash: 3610a70ce488953c5b0379fece70f2baad30a825
commit-date: 2017-07-05
host: x86_64-unknown-linux-gnu
release: 1.20.0-dev
LLVM version: 4.0
emcc: 1.37.15 (commit e99b50793a81b97a2559ec93fa49c7a0a8aaa4cc)
node: v8.1.2
config.toml:
[build]
submodules = false
target = ["x86_64-unknown-linux-gnu", "asmjs-unknown-emscripten", "wasm32-unknown-emscripten"]
[rust]
codegen-units = 48
debug-assertions = true
[llvm]
assertions = true
targets = "X86;JSBackend"
clean-rebuild = true
optimize = false
ccache = true
Metadata
Metadata
Assignees
Labels
No labels