-
Notifications
You must be signed in to change notification settings - Fork 30
Linking executable target failed when swift-tools-version >= 5.5 #3645
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
Comments
Don't we run an integration test for this on CI? I'm surprised CI for 5.5 passed while this issue is still reproducible. |
It seems our integration test only contains building library package. We need to add a test case for executable package also. |
swiftlang/swift-package-manager#3804 has been merged |
I see an executable target in the integration tests package here though, or am I missing something? https://github.com/swiftwasm/integration-tests/blob/master/Package.swift |
With swift-wasm-5.5-SNAPSHOT-2021-10-02-a
The latest SwiftPM rename main entry point name of executable target to avoid conflicting "main" with test target since
swift-tools-version >= 5.5
.The main symbol is renamed to "{{module_name}}_main" and it's renamed again to be "main" when linking the executable target. The former renaming is done by Swift compiler, and the latter is done by linker, so SwiftPM passes some special linker flags for each platform.
But SwiftPM assumes that wasm-ld supports it by returning an empty array instead of nil even though wasm-ld doesn't support it yet. https://github.com/apple/swift-package-manager/blob/1be68e811d0d814ba7abbb8effee45f1e8e6ec0d/Sources/Build/BuildPlan.swift#L117-L126
Current workaround for this issue is to put an explicit
main
decl using@_cdecl
like this:For a short-term solution, we need to disable the renaming in the SwiftPM. But for a long-term solution, this renaming feature should be supported on wasm-ld, so we should send a patch for it into lld.
The text was updated successfully, but these errors were encountered: