Skip to content

Emscripten optimizations are not used when building with the --release option #39626

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

Closed
davidMcneil opened this issue Feb 7, 2017 · 2 comments

Comments

@davidMcneil
Copy link

davidMcneil commented Feb 7, 2017

Emscripten optimizations are not used when building a project with:

cargo build --release --target asmjs-unknown-emscripten

The Emscripten optimization level can be forced by placing the following in a .cargo/config

[target.asmjs-unknown-emscripten]
rustflags = [
    "-Clink-args=-O3 --memory-init-file 0",
]

For example when building the following code...

use std::time::Instant;

fn main() {
    let start_time = Instant::now();
    let duration = start_time.elapsed();
    println!("Runtime {:.5} ms",
             (duration.as_secs() as f64) * 1000.0 +
             (duration.subsec_nanos() as f64) / 1_000_000.0);
}

and then running it using node target/asmjs-unknown-emscripten/release/example.js with and without the optimizations forced there is a noticeable difference between the two runtimes.

Meta

rustc 1.15.0 (10893a9 2017-01-19)
binary: rustc
commit-hash: 10893a9
commit-date: 2017-01-19
host: x86_64-unknown-linux-gnu
release: 1.15.0
LLVM version: 3.9

@RReverser
Copy link
Contributor

Looks like duplicate of #36899 which is implemented in nightly

@alexcrichton
Copy link
Member

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants