mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Merge pull request #2731 from rtfeldman/wasm-build-options
Optimize Wasm build options
This commit is contained in:
commit
dca9404772
5 changed files with 10 additions and 5 deletions
|
@ -2,3 +2,9 @@
|
||||||
test-gen-llvm = "test -p test_gen"
|
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-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"
|
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"]
|
||||||
|
|
|
@ -26,7 +26,6 @@ roc_target = {path = "../compiler/roc_target"}
|
||||||
roc_types = {path = "../compiler/types"}
|
roc_types = {path = "../compiler/types"}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["console_error_panic_hook"]
|
|
||||||
wasmer = ["futures"]
|
wasmer = ["futures"]
|
||||||
|
|
||||||
[package.metadata.wasm-pack.profile.profiling]
|
[package.metadata.wasm-pack.profile.profiling]
|
||||||
|
|
|
@ -3,7 +3,7 @@ mod repl;
|
||||||
//
|
//
|
||||||
// Interface with external JS in the browser
|
// Interface with external JS in the browser
|
||||||
//
|
//
|
||||||
#[cfg(not(feature = "wasmer"))]
|
#[cfg(feature = "console_error_panic_hook")]
|
||||||
extern crate console_error_panic_hook;
|
extern crate console_error_panic_hook;
|
||||||
#[cfg(not(feature = "wasmer"))]
|
#[cfg(not(feature = "wasmer"))]
|
||||||
mod externs_js;
|
mod externs_js;
|
||||||
|
|
|
@ -155,7 +155,7 @@ impl<'a> ReplApp<'a> for WasmReplApp<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn entrypoint_from_js(src: String) -> Result<String, String> {
|
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();
|
console_error_panic_hook::set_once();
|
||||||
|
|
||||||
let arena = &Bump::new();
|
let arena = &Bump::new();
|
||||||
|
|
|
@ -26,11 +26,11 @@ cp -r repl_www/public/* $WWW_ROOT
|
||||||
if [ -n "${REPL_DEBUG:-}" ]
|
if [ -n "${REPL_DEBUG:-}" ]
|
||||||
then
|
then
|
||||||
# Leave out wasm-opt since it takes too long when debugging, and provide some debug options
|
# 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/
|
wasm-bindgen --target web --keep-debug target/wasm32-unknown-unknown/release/roc_repl_wasm.wasm --out-dir repl_wasm/pkg/
|
||||||
else
|
else
|
||||||
# A `--profiling` build is optimized and has debug info, so we get stack traces for compiler `todo!()`
|
# 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
|
fi
|
||||||
|
|
||||||
cp repl_wasm/pkg/*.wasm $WWW_ROOT
|
cp repl_wasm/pkg/*.wasm $WWW_ROOT
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue