[SR-6857] Duplicate Symbols when Statically Linking on Windows #49406
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
Environment
Tested on Ubuntu 16.04, cross-compiling for Windows 10 x64 using lld-link.
Additional Detail from JIRA
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 text was updated successfully, but these errors were encountered: