Skip to content

Tests fail to link on Windows when macros are present #7174

Open
@lynchsft

Description

@lynchsft

Description

Tests fail to link on Windows using swift 5.9.1-RELEASE when macros are present.

This is a trivial repo that reproduces the issue:
https://github.com/lynchsft/swift-windows-macro-testing

The locus of this problem is on Windows platform, but I conclude that it indirectly negatively affects the entire Swift community. As macros proliferate through common libraries, all swift-on-windows tools will either have to abandon testing or wholly abandon windows as a platform. Neither of these outcomes speaks well of the "swift is a cross platform language" story.

Particularly, I'm asserting that this is a rapidly worsening problem because library authors that don't usually concern themselves with Windows are eagerly adopting macros feature. Soon, the libraries that Windows projects currently rely on will be un-ingestiable, effectively locking our dependences at the last-macro-free version.
This in turn, is a security problem as code-currency (up-to-date dependencies) are a crucial topic for averting and responding to security threats.

@neonichu, @MaxDesiatov During construction of that ^^ trivial reproduction repo, I actually encountered a success case, where I WAS able to ingest a macro and use it on Windows. The linker error did not arise.
Including this state in case its a useful resource to have.

Branch: success_case
Repo: https://github.com/lynchsft/swift-windows-macro-testing

Expected behavior

The tests should link and run properly.

Actual behavior

The tests fail to link (compilation succeeds):

Building for debugging...
lld-link: error: duplicate symbol: main
>>> defined at C:\Users\lynchsft\swift-windows-macro-testing\.build\x86_64-unknown-windows-msvc\debug\PowerAssertPlugin.build\PowerAssertPlugin.swift.o
>>> defined at C:\Users\lynchsft\swift-windows-macro-testing\.build\x86_64-unknown-windows-msvc\debug\SwiftWindowsPackageTestingPackageTests.build\runner.swift.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[238/239] Linking C:\Users\lynchsft\swift-windows-macro-testing\.build\x86_64-unknown-windows-msvc\debug\SwiftWindowsPackageTestingPackageTests.xctest
error: fatalError

Steps to reproduce

swift --test

Swift Package Manager version/commit hash

5.9.1-RELEASE

Swift & OS version (output of swift --version ; uname -a)

Swift version 5.9.1 (swift-5.9.1-RELEASE)
Target: x86_64-unknown-windows-msvc
MSYS_NT-10.0-22631 lynchal-z01 3.4.6.x86_64 2023-05-18 20:39 UTC x86_64 Msys

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions