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

🍒 [WebAssembly] Add segment RETAIN flag to support private retained data #8238

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Feb 20, 2024

Cherry-pick llvm@ba3c1f9 to enable --gc-sections for WebAssembly targets. With this fine-grained GC control, we can drop --no-gc-sections passed by driver and it removes unused import section entries and will get much smaller binary.

llvm#81539)

In WebAssembly, we have `WASM_SYMBOL_NO_STRIP` symbol flag to mark the
referenced content as retained. However, the flag is not enough to
express retained data that is not referenced by any symbol. This patch
adds a new segment flag`WASM_SEG_FLAG_RETAIN` to support "private"
linkage data that is retained by llvm.used.

This kind of data that is not referenced but must be retained is usually
used with encapsulation symbols (__start/__stop). Swift runtime uses
this technique and depends on the fact "all metadata sections in live
objects are retained", which was not guaranteed with `--gc-sections`
before this patch.

This is a revised version of https://reviews.llvm.org/D126950 (has been
reverted) based on @MaskRay's comments
@kateinoigakukun kateinoigakukun marked this pull request as ready for review February 20, 2024 18:43
@MaxDesiatov
Copy link

@swift-ci test

@MaxDesiatov MaxDesiatov requested a review from bnbarham February 20, 2024 18:45
@kateinoigakukun
Copy link
Member Author

@swift-ci Please test macOS platform

@kateinoigakukun kateinoigakukun merged commit 2fb73f1 into swiftlang:stable/20230725 Feb 21, 2024
3 checks passed
@kateinoigakukun kateinoigakukun deleted the yt/cherry-pick-no-strip-wasm branch February 21, 2024 01:57
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