swiftwasm / swift

WebAssembly support for the Swift programming language

Home Page:https://swiftwasm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

kateinoigakukun opened this issue · comments

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.

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

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