-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
[wasm] Enable --gc-sections
for WebAssembly by default
#71768
Merged
kateinoigakukun
merged 1 commit into
swiftlang:main
from
kateinoigakukun:pr-5b0947b86ee45b937e9b6fedd0963644227b754d
Feb 21, 2024
Merged
[wasm] Enable --gc-sections
for WebAssembly by default
#71768
kateinoigakukun
merged 1 commit into
swiftlang:main
from
kateinoigakukun:pr-5b0947b86ee45b937e9b6fedd0963644227b754d
Feb 21, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This change enables the `--gc-sections` linker flag for WebAssembly targets by default. This flag has been disabled because it did not respect `llvm.used` and it caused stripping `swift5` metadata sections even though they were used through encapsulation symbols (a.k.a `__start`/`__stop`). The issue has been fixed in the LLVM side (llvm/llvm-project@ba3c1f9) by adding new segment flags to the WebAssembly object file format.
preset=buildbot_linux_crosscompile_wasm |
@swift-ci Please smoke test |
kateinoigakukun
added a commit
to kateinoigakukun/swift-package-manager
that referenced
this pull request
Feb 21, 2024
This effectively reverts 3a366cc. After swiftlang/swift#71768, we don't have any reason to disable `--gc-sections` for WebAssembly targets. Note that the new wasm segment flags are only supported by the latest LLVM and wasm-ld, but we can assume that toolchains or Swift SDKs for WebAssembly have wasm-ld built from the latest LLVM.
@swift-ci Please smoke test |
kateinoigakukun
added a commit
to kateinoigakukun/swift-package-manager
that referenced
this pull request
Feb 21, 2024
This effectively reverts 3a366cc. After swiftlang/swift#71768, we don't have any reason to disable `--gc-sections` for WebAssembly targets. Note that the new wasm segment flags are only supported by the latest LLVM and wasm-ld, but we can assume that toolchains or Swift SDKs for WebAssembly have wasm-ld built from the latest LLVM.
@swift-ci Please smoke test Windows platform |
MaxDesiatov
approved these changes
Feb 21, 2024
MaxDesiatov
pushed a commit
to swiftlang/swift-package-manager
that referenced
this pull request
Feb 21, 2024
Enable `--gc-sections` back for WebAssembly targets ### Motivation: We disabled `--gc-sections` for Wasm targets due to a lack of features in the object file format. However, we recently added the missing piece in wasm object file format, so we no longer have any reason to disable it. ### Modifications: This effectively reverts 3a366cc. After swiftlang/swift#71768, we don't have any reason to disable `--gc-sections` for WebAssembly targets. Note that the new wasm segment flags are only supported by the latest LLVM and wasm-ld, but we can assume that toolchains or Swift SDKs for WebAssembly have wasm-ld built from the latest LLVM. ### Result: Allow dead code stripping at link time for WebAssembly targets.
furby-tm
pushed a commit
to wabiverse/swift-package-manager
that referenced
this pull request
May 15, 2024
Enable `--gc-sections` back for WebAssembly targets ### Motivation: We disabled `--gc-sections` for Wasm targets due to a lack of features in the object file format. However, we recently added the missing piece in wasm object file format, so we no longer have any reason to disable it. ### Modifications: This effectively reverts 3a366cc. After swiftlang/swift#71768, we don't have any reason to disable `--gc-sections` for WebAssembly targets. Note that the new wasm segment flags are only supported by the latest LLVM and wasm-ld, but we can assume that toolchains or Swift SDKs for WebAssembly have wasm-ld built from the latest LLVM. ### Result: Allow dead code stripping at link time for WebAssembly targets.
furby-tm
pushed a commit
to wabiverse/swift-package-manager
that referenced
this pull request
May 15, 2024
Enable `--gc-sections` back for WebAssembly targets ### Motivation: We disabled `--gc-sections` for Wasm targets due to a lack of features in the object file format. However, we recently added the missing piece in wasm object file format, so we no longer have any reason to disable it. ### Modifications: This effectively reverts 3a366cc. After swiftlang/swift#71768, we don't have any reason to disable `--gc-sections` for WebAssembly targets. Note that the new wasm segment flags are only supported by the latest LLVM and wasm-ld, but we can assume that toolchains or Swift SDKs for WebAssembly have wasm-ld built from the latest LLVM. ### Result: Allow dead code stripping at link time for WebAssembly targets.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change enables the
--gc-sections
linker flag for WebAssembly targets by default. This flag has been disabled because it did not respectllvm.used
and it caused strippingswift5
metadata sections even though they were used through encapsulation symbols (a.k.a__start
/__stop
).The issue has been fixed in the LLVM side (llvm/llvm-project@ba3c1f9) by adding new segment flags to the WebAssembly object file format, which is represented by
"R"
flag in assembly orllvm.used
in LLVM IR.