Merge pull request #2731 from rtfeldman/wasm-build-options

Optimize Wasm build options
This commit is contained in:
Richard Feldman 2022-03-16 22:29:07 -04:00 committed by GitHub
commit dca9404772
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 5 deletions

View file

@ -2,3 +2,9 @@
test-gen-llvm = "test -p test_gen"
test-gen-dev = "test -p roc_gen_dev -p test_gen --no-default-features --features gen-dev"
test-gen-wasm = "test -p roc_gen_wasm -p test_gen --no-default-features --features gen-wasm"
[target.wasm32-unknown-unknown]
# Rust compiler flags for minimum-sized .wasm binary in the web REPL
# opt-level=s Optimizations should focus more on size than speed
# lto=fat Spend extra effort on link-time optimization across crates
rustflags = ["-Copt-level=s", "-Clto=fat"]

View file

@ -26,7 +26,6 @@ roc_target = {path = "../compiler/roc_target"}
roc_types = {path = "../compiler/types"}
[features]
default = ["console_error_panic_hook"]
wasmer = ["futures"]
[package.metadata.wasm-pack.profile.profiling]

View file

@ -3,7 +3,7 @@ mod repl;
//
// Interface with external JS in the browser
//
#[cfg(not(feature = "wasmer"))]
#[cfg(feature = "console_error_panic_hook")]
extern crate console_error_panic_hook;
#[cfg(not(feature = "wasmer"))]
mod externs_js;

View file

@ -155,7 +155,7 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
}
pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
#[cfg(not(feature = "wasmer"))]
#[cfg(feature = "console_error_panic_hook")]
console_error_panic_hook::set_once();
let arena = &Bump::new();

View file

@ -26,11 +26,11 @@ cp -r repl_www/public/* $WWW_ROOT
if [ -n "${REPL_DEBUG:-}" ]
then
# Leave out wasm-opt since it takes too long when debugging, and provide some debug options
cargo build --target wasm32-unknown-unknown -p roc_repl_wasm --release
cargo build --target wasm32-unknown-unknown -p roc_repl_wasm --release --features console_error_panic_hook
wasm-bindgen --target web --keep-debug target/wasm32-unknown-unknown/release/roc_repl_wasm.wasm --out-dir repl_wasm/pkg/
else
# A `--profiling` build is optimized and has debug info, so we get stack traces for compiler `todo!()`
wasm-pack build --profiling --target web repl_wasm
wasm-pack build --profiling --target web repl_wasm -- --features console_error_panic_hook
fi
cp repl_wasm/pkg/*.wasm $WWW_ROOT