diff options
author | Alon Zakai <azakai@google.com> | 2024-11-04 16:49:17 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-04 16:49:17 -0800 |
commit | 320867a7c61432691faa62892d5fd89e4f6bae6a (patch) | |
tree | 9156ddc92384738ff38c87b22e7ffbd68e133112 /scripts | |
parent | 884261afa7ff6d0158f3a1882e0247568c8d6cda (diff) | |
download | binaryen-320867a7c61432691faa62892d5fd89e4f6bae6a.tar.gz binaryen-320867a7c61432691faa62892d5fd89e4f6bae6a.tar.bz2 binaryen-320867a7c61432691faa62892d5fd89e4f6bae6a.zip |
Add a J2CL compiler script (#7052)
J2CL runs a long pipeline of binaryen opts, including multiple invocations. This adds a
tool that simulates the same process manually, which can be easier to debug with
than running a full J2CL toolchain, which requires Bazel, etc. - this is just a few lines of
bash that does the same thing (at least in simple cases).
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/j2cl.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/j2cl.sh b/scripts/j2cl.sh new file mode 100644 index 000000000..884001aea --- /dev/null +++ b/scripts/j2cl.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -e + +# +# Simplified version of +# +# https://github.com/google/j2cl/blob/e0dee1c7a726952c93d6ace95ddc39c7a6bcc74a/build_defs/internal_do_not_use/j2wasm_application.bzl#L4 +# +# This can be useful for local testing of issues with j2cl output, by running +# this instead of setting up a full j2cl toolchain. Usage: +# +# j2cl.sh input.wasm output.wasm +# +# This will emit one file for each stage of compilation, as output.wasm.N.wasm. +# + +COMMON="--enable-exception-handling --enable-gc --enable-reference-types --enable-sign-ext --enable-strings --enable-nontrapping-float-to-int --enable-bulk-memory --closed-world --traps-never-happen" + +echo "Stage 1" +bin/wasm-opt $COMMON "--no-inline=*_<once>_*" -O3 --cfp-reftest --optimize-j2cl --gufa --unsubtyping -O3 --cfp-reftest --optimize-j2cl -O3 --cfp-reftest --optimize-j2cl $1 -o $2.1.wasm + +echo "Stage 2" +bin/wasm-opt $COMMON "--no-inline=*_<once>_*" --partial-inlining-ifs=4 -fimfs=25 --gufa --unsubtyping -O3 --cfp-reftest --optimize-j2cl -O3 --cfp-reftest --optimize-j2cl -O3 --cfp-reftest --optimize-j2cl --gufa --unsubtyping -O3 --cfp-reftest --optimize-j2cl -O3 --cfp-reftest --optimize-j2cl $2.1.wasm -o $2.2.wasm + +echo "Stage 3" +bin/wasm-opt $COMMON "--no-full-inline=*_<once>_*" --partial-inlining-ifs=4 --intrinsic-lowering --gufa --unsubtyping -O3 --cfp-reftest --optimize-j2cl -O3 --optimize-j2cl --cfp-reftest --type-merging -O3 --cfp-reftest --optimize-j2cl --string-lowering --remove-unused-module-elements --reorder-globals --type-finalizing $2.2.wasm -o $2.3.wasm + |