Skip to content
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

[SR-6857] Duplicate Symbols when Statically Linking on Windows #49406

Closed
troughton opened this issue Jan 27, 2018 · 2 comments
Closed

[SR-6857] Duplicate Symbols when Statically Linking on Windows #49406

troughton opened this issue Jan 27, 2018 · 2 comments
Assignees
Labels
affects ABI Flag: Affects ABI bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself swift 4.0 Windows Platform: Windows

Comments

@troughton
Copy link
Contributor

Previous ID SR-6857
Radar None
Original Reporter @troughton
Type Bug
Status Resolved
Resolution Done
Environment

Tested on Ubuntu 16.04, cross-compiling for Windows 10 x64 using lld-link.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, AffectsABI, Swift4, Windows
Assignee @compnerd
Priority Medium

md5: 2962b39978a55b59b8ec5f9c40007f6f

Issue Description:

When statically linking Swift programs for Windows, duplicate symbols are emitted, preventing the object files/libs from being linked without /force:multiple (which is only supported on `link.exe` and not in LLD. This can be worked around by e.g. patching lld's COFF backend to ignore multiple definitions.

error: duplicate symbol: $Ss14CountableRangeVySiGAByxGs23BidirectionalCollectionsWL in /main.swift.o and in swiftcore.lib(swift.o)

error: duplicate symbol: __swift_memcpy24_8 in main.swift.o and in swiftcore.lib(swift.o)

error: duplicate symbol: $Ss23_ContiguousArrayStorageCyypGML in swiftcore.lib(swift.o) and in swiftswiftononesupport.lib(swiftononesupport.o)

Some of these functions should likely be marked 'COMDAT', so that they are used only when the compiler doesn't emit the implementation.

Similarly, swift_rt functions are (likely incorrectly) being exported twice:

/usr/bin/lld-link: error: duplicate symbol: swift_rt_swift_retain in main.swift.o and in swiftcore.lib(swift.o)
{{ /usr/bin/lld-link: error: duplicate symbol: swift_rt_swift_release in main.swift.o and in swiftcore.lib(swift.o)}}

which may also be a bug; as per @compnerd:

"The `swift_rt_` functions should not be exported I believe, as they are meant to be the local trampolines."

@belkadan
Copy link
Contributor

I think we just don't get dllimport/export right on anything right now, other than whatever experiments the few Windows adopters have been doing.

@compnerd
Copy link
Collaborator

I believe that this should now be fixed with my work to enable the COMDAT on Windows.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects ABI Flag: Affects ABI bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself swift 4.0 Windows Platform: Windows
Projects
None yet
Development

No branches or pull requests

3 participants