Skip to content

Conversation

MaxDesiatov
Copy link
Contributor

This provides an example of DOM manipulation using reference types. With all optimizations enabled, final .build/release/RefsTest.wasm binary built using Embedded Swift SDK is only 1.2 kB.

@MaxDesiatov MaxDesiatov requested a review from bnbarham August 5, 2025 16:31
@MaxDesiatov MaxDesiatov added the documentation Improvements or additions to documentation label Aug 5, 2025
@MaxDesiatov
Copy link
Contributor Author

@kateinoigakukun would you have a moment to review this at some point?

@MaxDesiatov MaxDesiatov merged commit 97aabc5 into main Aug 15, 2025
37 checks passed
@MaxDesiatov MaxDesiatov deleted the maxd/externref branch August 15, 2025 08:05
@zaneenders
Copy link
Contributor

Hi, I'm wondering what you did to get 1.2kb? I'm seeing 23kb with the following command.

swift build -c release  --swift-sdk swift-6.2-DEVELOPMENT-SNAPSHOT-2025-09-06-a_wasm-embedded

Swift version 6.2-dev (LLVM 1b5a5a47cc92b04, Swift 7ec75e941fbfc24)
Target: aarch64-unknown-linux-gnu
Build config: +assertions

@MaxDesiatov
Copy link
Contributor Author

MaxDesiatov commented Sep 9, 2025

@zaneenders you have to pass -c release to your swift build invocation, e.g. this way:

swift build --swift-sdk "$(swiftc -print-target-info | jq -r '.swiftCompilerTag')_wasm-embedded" \
  -c release

Then run wasm-opt with these options:

wasm-opt .build/release/*.wasm -Oz --strip-debug --inlining-optimizing -cw -c --dae-optimizing \
  --local-cse --gufa-optimizing -o opt.wasm

Verify the final size:

wc -c opt.wasm

Output for the last command for me is 1297 bytes when using swift-DEVELOPMENT-SNAPSHOT-2025-09-07-a and wasm-opt version 124.

@zaneenders
Copy link
Contributor

That worked. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants