Description
Describe the Bug and Steps to Reproduce
First of all, an apology because I've been unable to make a shorter program that shows this issue: it only happens when I compile the full program.
When building my wasm program RAZE with this command and the latest wasm-bindgen:
$ cargo update
$ wasm-pack build --no-typescript --target no-modules --release
It gives the following error:
error: cannot import from modules (
env
) with--no-modules
Changing to --target web
it does build, but it emits this line into the generated JS:
import * as __wbg_star0 from 'env';
that breaks the runtime. If I remove any reference to the env
module (and rework all my JS to work with modules) it works nice, which proves that the env
module, whatever it is, is not actually needed.
NOTE: I've patched the wasm-opt
bundled with wasm-pack
with wasm-opt version 93
, because the bundled one (version 90 I think) crashes.
Expected Behavior
The env
module should not be needed.
What causes the env
reference.
Disassembling the .wasm file in directory target
, I find this line:
(import "env" "_ZN4core9panicking18panic_bounds_check17h95b04dd9865918b6E" (func $_ZN4core9panicking18panic_bounds_check17h95b04dd9865918b6E (param i32 i32 i32)))
which is weird because this function is actually defined inside the wasm itself, not externally.
Even weirder, if I comment out the call to f32::sin()
in this line, the problem disappears. although the function panic_bounds_check
still exists in the wasm (no env
though).
I've tried extracting this whole module to a simpler project, but then the problem simply does not happen.
Versions used:
- rustc 1.44.0-beta.4 or 1.45.0-nightly (a74d1862d 2020-05-14)
- wasm-pack 0.9.1
- wasm-bindgen 0.2.62 (d896446)
- wasm-opt 93