Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a pass to remove exports from the WASM bundle #6844

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

loganek
Copy link
Contributor

@loganek loganek commented Aug 16, 2024

This is helpful when e.g. there's a WASM shared library with all possible functions exported but the application only needs a subset of those exports. Removing exports in that case will enable further optimizers to remove more code from the file.

@loganek
Copy link
Contributor Author

loganek commented Aug 16, 2024

@kripken based on my tests the pass is executed before passes for removing dead code, but I wasn't sure if that's just coincident or a stable behavior. Could you confirm if that's the case (otherwise users would have to call wasm-opt twice to get all the optimizations) or is there anything I could do to make this explicit? Many thanks.

@kripken
Copy link
Member

kripken commented Aug 16, 2024

Before getting into details here, please see this wiki page:

https://github.com/WebAssembly/binaryen/wiki/Pruning-unneeded-code-in-wasm-files-with-wasm-metadce#example-pruning-exports

wasm-metadce can prune exports, perhaps that is enough for your use case?

@loganek
Copy link
Contributor Author

loganek commented Aug 16, 2024

Thanks for sharing. This sort of solves the problem I'm trying to solve; one difference here is that for wasm-metadce you need to define reachable nodes, whereas this pass does it other way around (you define exports that you don't need). I think it's a bit more scripting to define all reachable functions in my case, but I can definitely live with that. Up to you then whether you want to merge it or close.

This is helpful when e.g. there's a WASM shared library with all possible
functions exported but the application only needs a subset of those exports.
Removing exports in that case will enable further optimizers to remove more
code from the file.
@kripken
Copy link
Member

kripken commented Aug 22, 2024

I see, thanks. I don't feel strongly, then, since it somewhat different. Maybe let's keep it open and see if other people comment that they could benefit as well - if so, I think we should land it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants