Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken examples when compiling with nightly rust and following size optimizations #2696

Closed
1 task done
WorldSEnder opened this issue May 20, 2022 · 0 comments · Fixed by #2695
Closed
1 task done
Labels
A-ci Area: The continuous integration A-examples Area: The examples blocked bug

Comments

@WorldSEnder
Copy link
Member

WorldSEnder commented May 20, 2022

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

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

undefined symbol: core::intrinsics::const_eval_select

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.

Expected behavior

A clean and working wasm is produced.

Environment:

  • Yew version: master
  • Rust version: rustc 1.62.0-nightly (18f314e70 2022-04-24)
  • Build tool, if relevant: trunk

Questionnaire

  • I would like to fix and I have a solution
@WorldSEnder WorldSEnder added A-examples Area: The examples A-ci Area: The continuous integration blocked labels May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ci Area: The continuous integration A-examples Area: The examples blocked bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant