-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Duplicate main
symbol for swift test
on Windows
#6367
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
Sounds as if cc @compnerd |
@neonichu that definitely works: https://github.com/compnerd/swift-win32-application/blob/main/Package.swift even has an example. The problem is that you cannot alias functions using the linker on Windows and this needs to be done in SPM. |
I think that I have a solution to this that is cross-platform as long as we are reliant on LLVM! The symbol rewriter should do this properly on all file formats! |
Oof; I should have searched for this before creating the minimal reproducer. But there it is in case it helps! Be sure you get the spm-bug-windows-test-executable-dependency tag. |
@MaxDesiatov Do you think this issue would be resolved now with your cross-compilation macros work? |
I'm still seeing it recently with swift-foundation at least. |
This may not work and still be blocked by swiftlang/swift-package-manager#6367. Would close #5.
This uses the /ALTERNATENAME flag to link.exe, which is roughly equivalent to -alias/--defsym. This has been verified to work in a sample project. See https://devblogs.microsoft.com/oldnewthing/20200731-00/ for more info. Closes #6367
This uses the /ALTERNATENAME flag to link.exe, which is roughly equivalent to -alias/--defsym. This has been verified to work in a sample project. See https://devblogs.microsoft.com/oldnewthing/20200731-00/ for more info. Closes #6367
Description
I have a package with an executable target, and a test target. The tests in the test target do a
@testable import
of the executable target. The main target has a@main struct ...
.Running
swift test
works on macOS and Linux.Running
swift test
on Windows fails.Expected behavior
When running
swift test
on Windows, the tests run.Actual behavior
When running
swift test
on windows, it fails with an error at link time:Steps to reproduce
No response
Swift Package Manager version/commit hash
version included in the official Swift download for Windows
Swift & OS version (output of
swift --version && uname -a
)Swift: 5.8
OS: Microsoft Windows Server 2022
(also happens on other versions of swift and OS).
The text was updated successfully, but these errors were encountered: