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

Enable wasm-ld's --gc-sections option for code size and import requirements #5128

Closed
kateinoigakukun opened this issue Jan 3, 2023 · 3 comments
Labels
llvm Need LLVM changes

Comments

@kateinoigakukun
Copy link
Member

kateinoigakukun commented Jan 3, 2023

Now wasm-ld strips data segments referenced through __start/__stop symbols during GC, and it removes Swift metadata sections like swift5_protocols
We should add support of SHF_GNU_RETAIN-like flag for __attribute__((retain)) to LLVM and wasm-ld. For now, just disable section GC for Wasm target.

@kateinoigakukun
Copy link
Member Author

The recent wasi-libc introduced sock_accept WASI function import, but it's not widely implemented in major runtimes.
Without link-time GC, all import entries are retained in the final binary, so produced binaries are not compatible with those runtimes even though sock_accept is not used in user code.
This issue blocks #5127

@kateinoigakukun kateinoigakukun added the llvm Need LLVM changes label Jan 3, 2023
kateinoigakukun added a commit to swiftwasm/carton that referenced this issue Jan 16, 2024
The recent wasi-libc includes some new syscalls not implemented in
@wasmer-js/wasi and we currently disable `--gc-sections` (see
swiftwasm/swift#5128), so binaries built with
SwiftWasm 5.9 toolchain contains references to those unimplemented
syscalls.
This commit allows running such binaries by inserting dummy functions
for unimplemented syscalls.
kateinoigakukun added a commit to swiftwasm/carton that referenced this issue Jan 16, 2024
The recent wasi-libc includes some new syscalls not implemented in
@wasmer-js/wasi and we currently disable `--gc-sections` (see
swiftwasm/swift#5128), so binaries built with
SwiftWasm 5.9 toolchain contains references to those unimplemented
syscalls.
This commit allows running such binaries by inserting dummy functions
for unimplemented syscalls.
@kateinoigakukun
Copy link
Member Author

@kateinoigakukun
Copy link
Member Author

Based on my experiments, hello world program is now smaller: 7.1MB -> 6.7MB (-5%)

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

No branches or pull requests

1 participant