-
Notifications
You must be signed in to change notification settings - Fork 449
Description
🐛 Bug description
npm run start
fails when running a wasm module that was built from Rust with C++ dependency using wasm-pack
. Inspecting the generated wasm module shows that it tries to import (import "env" "double_it" (func $double_it (type $t5)))
from a module "env" that it doesn't know ("double_it" is the function in the C++ dependency). The C++ dependency is actually a C file which has been renamed to have a ".cpp" ending. npm run start
works with the ".c" file. So maybe the ".cpp" ending triggers different compilation flags that yield the different result. Since both C and C++ compile to wasm I thought there should be no difference in the usage.
A same problem has been initially encountered also for the ".c" file in the comment: #621 (comment). The problem was potentially resolved with a newer clang or Rust update.
Project available here: https://github.com/JanKaul/simple-wasm
🤔 Expected Behavior
npm run start
should succeed.
👟 Steps to reproduce
- C++ dependency build with
cc
crate, which determines compiler automatically (I guessclang
) wasm-pack build
succeedsnpm install
succeedsnpm run strart
fails with following error:
ERROR in ../pkg/simple_wasm_bg.wasm
Module not found: Error: Can't resolve 'env' in '/home/user/workspace/rust/simple-wasm/pkg'
@ ../pkg/simple_wasm_bg.wasm
@ ../pkg/simple_wasm.js
@ ./index.js
@ ./bootstrap.js
ℹ 「wdm」: Failed to compile.
🌍 Your environment
wasm-pack 0.8.1
rustc 1.39.0 (4560ea788 2019-11-04)
clang version 9.0.0-2 (tags/RELEASE_900/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin