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
When following the size recommendations from the Optimization page and compiling the boids and password_size examples in current nightly rust, they fail to produce browser-compatible javascript.
The be more precise the generated js causes an error when loaded by the browser such as
Uncaught TypeError: Error resolving module specifier “env”. Relative module specifiers must start with “./”, “../” or “/”.
The deeper problem is two-fold. First, a compiler bug, rust-lang/rust#96486, results in some symbols in the binary, mainly
This error is then converted, I assume by wasm-bindgen, to an externally linked method and "mitigated" by generating an import for the (non-existent) env module in the generated javascript wrapper. I think it should rather error out, as it effectively hides a compiler bug, but it is what it be.
Steps To Reproduce
Enable the following options in .cargo/config.toml
[unstable]
build-std = ["std"]
and lto in Cargo.toml
[profile.release]
# optimization for size ( more aggressive )
opt-level = 'z'
# link time optimization using using whole-program analysis
lto = true
Then compile the examples with RUSTUP_TOOLCHAIN="nightly" trunk build --release.
Problem
When following the size recommendations from the Optimization page and compiling the boids and password_size examples in current nightly rust, they fail to produce browser-compatible javascript.
The be more precise the generated js causes an error when loaded by the browser such as
The deeper problem is two-fold. First, a compiler bug, rust-lang/rust#96486, results in some symbols in the binary, mainly
This error is then converted, I assume by wasm-bindgen, to an externally linked method and "mitigated" by generating an import for the (non-existent)
env
module in the generated javascript wrapper. I think it should rather error out, as it effectively hides a compiler bug, but it is what it be.Steps To Reproduce
Enable the following options in
.cargo/config.toml
and lto in
Cargo.toml
Then compile the examples with
RUSTUP_TOOLCHAIN="nightly" trunk build --release
.Expected behavior
A clean and working wasm is produced.
Environment:
master
rustc 1.62.0-nightly (18f314e70 2022-04-24)
trunk
Questionnaire
The text was updated successfully, but these errors were encountered: