Skip to content

Stop using --gc-sections for Wasm target to protect metadata sections#5638

Merged
MaxDesiatov merged 1 commit into
swiftlang:mainfrom
swiftwasm:katei/void-gc-sections-on-wasm
Jul 10, 2022
Merged

Stop using --gc-sections for Wasm target to protect metadata sections#5638
MaxDesiatov merged 1 commit into
swiftlang:mainfrom
swiftwasm:katei/void-gc-sections-on-wasm

Conversation

@kateinoigakukun

@kateinoigakukun kateinoigakukun commented Jul 3, 2022

Copy link
Copy Markdown
Member

Stop using --gc-sections for Wasm target to protect metadata sections

Motivation:

Now wasm-ld strips data segments referenced through __start/__stop symbols
during GC, and it removes Swift metadata sections like swift5_protocols.
This option has been added in #4135

Modifications:

We should add support for SHF_GNU_RETAIN-like flag for attribute((retain))
to LLVM and wasm-ld.
For now, just disable section GC for Wasm target.

Context

Result:

Swift metadata sections are retained in the final executable in release configuration for Wasm target.

CC: @MaxDesiatov @keith

@kateinoigakukun

Copy link
Copy Markdown
Member Author

@swift-ci Please smoke test

@keith keith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems good, we should definitely do that TODO for binary size sake

Comment thread Sources/Build/BuildPlan.swift
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 kateinoigakukun force-pushed the katei/void-gc-sections-on-wasm branch from 4f68200 to 9722969 Compare July 7, 2022 19:44
@kateinoigakukun

Copy link
Copy Markdown
Member Author

@swift-ci Please smoke test

@MaxDesiatov MaxDesiatov merged commit 3a366cc into swiftlang:main Jul 10, 2022
@kateinoigakukun kateinoigakukun deleted the katei/void-gc-sections-on-wasm branch July 10, 2022 09:58
kateinoigakukun added a commit to swiftwasm/swift-package-manager that referenced this pull request Jul 10, 2022
…ns (swiftlang#5638)

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.

Context:
llvm/llvm-project#55839
https://reviews.llvm.org/D126950#3558050
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants