Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion examples/js-tiny/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,20 @@ diplomat.config.mjs:
target/wasm32-unknown-unknown/release/icu_capi.wasm: FORCE
rustup toolchain install ${LLVM_COMPATIBLE_NIGHTLY}
rustup component add rust-src --toolchain ${LLVM_COMPATIBLE_NIGHTLY}
# Build the WASM library
# Build the WASM library. Explanation of the flags:
# -Cpanic=abort: removes unwind machinery
# -Copt-level=s: tells llvm to optimize for size
# -C link-arg=-zstack-size=${WASM_STACK_SIZE}: the default is too large and contributes to high runtime memory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is because of compiler bugs, no? 100k is a pretty large stack size, I think we set it to be larger than the default

# -Clinker-plugin-lto: add symbols to object files that enable link-time optimization
# -Ccodegen-units=1: generate the code in a single process to enable more opportunities for optimization
# -C linker=${BASEDIR}/ld.py: run a custom linker script to remove symbols
# -C linker-flavor=wasm-ld: tells rustc to pass the arguments to ld.py as it would pass to wasm-ld
# -Clto: run link-time optimization when building object files
# -Cembed-bitcode: retain llvm bitcode in the object files
# -Zwasm-c-abi=spec: use the new standard Rust-Wasm interface
RUSTFLAGS="-Cpanic=abort -Copt-level=s -C link-arg=-zstack-size=${WASM_STACK_SIZE} -Clinker-plugin-lto -Ccodegen-units=1 -C linker=${BASEDIR}/ld.py -C linker-flavor=wasm-ld -Clto -Cembed-bitcode -Zwasm-c-abi=spec" \
# -Z build-std=std,panic_abort: rebuild the standard library with panic-abort behavior
# -Z build-std-features=panic_immediate_abort: don't link debug impls when panicking, significantly reducing code size\
cargo +${LLVM_COMPATIBLE_NIGHTLY} rustc \
-Z build-std=std,panic_abort -Z build-std-features=panic_immediate_abort \
--target wasm32-unknown-unknown \
Expand Down
Loading