swiftlang / vscode-swift

Visual Studio Code Extension for Swift
https://marketplace.visualstudio.com/items?itemName=sswg.swift-lang
Apache License 2.0
755 stars 54 forks source link

Fix linker error when building Windows tests w/ coverage #942

Closed plemarquand closed 4 months ago

plemarquand commented 4 months ago

This fixes the fatalError seen on Windows when attempting to build tests with code coverage enabled. The linker doesn't allow duplicate symbols by default on Windows, while this is OK on macOS/Linux.

Use the -lldmingw linker flag to work around this issue.

plemarquand commented 4 months ago

@adam-fowler Basically the background is the --enable-code-coverage flag is currently causing a fatalError on Windows because during instrumentation the same symbol is inserted into multiple places, which the linker then fails to link since it doesn't support duplicate symbols on Windows.

This seems to be desired behaviour to match the existing windows linker (link.exe), but the output of --enable-code-coverage wasn't designed for this. In the future there will be something like -lld-allow-duplicate-weak which on Windows SPM will pass automatically when it sees --enable-code-coverage.