Swift 6.2 linker fails to find private symbol SwiftSyntax.SyntaxRewriter.visitationFunc depending on the number of parallel jobs
bug
### Description
The error is occurring on macOS and Linux platforms using swift 6.2 release compiler and swift-syntax 602.0.0, and the typical error message are
on Linux (using the official swift:noble docker image):
```
error: link command failed with exit code 1 (use -v to see invocation)
/thebug/.build/aarch64-unknown-linux-gnu/debug/CasePathsMacros-tool.build/CasePathableMacro.swift.o:CasePathableMacro.swift.o:$s15CasePathsMacros12SelfRewriterCMf:(.data+0x1358): error: undefined reference to '$s11SwiftSyntax0B8RewriterC14visitationFunc33_F0C5D882E9301122F145EADC4573BFC8LL3forAA0B0VAHcAH_tF'
/thebug/.build/aarch64-unknown-linux-gnu/debug/CasePathsMacros-tool.build/CasePathableMacro.swift.o:CasePathableMacro.swift.o:$s15CasePathsMacros15ElementRewriterCMf:(.data+0x2670): error: undefined reference to '$s11SwiftSyntax0B8RewriterC14visitationFunc33_F0C5D882E9301122F145EADC4573BFC8LL3forAA0B0VAHcAH_tF'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[255/327] Linking CasePathsMacros-tool
error: fatalError
```
on macOS 15.7.1, swiftlang-6.2.0.19.9 clang-1700.3.19.1:
```
error: link command failed with exit code 1 (use -v to see invocation)
Undefined symbols for architecture arm64:
"SwiftSyntax.SyntaxRewriter.(visitationFunc in _F0C5D882E9301122F145EADC4573BFC8)(for: SwiftSyntax.Syntax) -> (SwiftSyntax.Syntax) -> SwiftSyntax.Syntax", referenced from:
full type metadata for CasePathsMacros.SelfRewriter in CasePathableMacro.swift.o
full type metadata for CasePathsMacros.ElementRewriter in CasePathableMacro.swift.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[364/373] Linking CasePathsMacros-tool
error: fatalError
```
We have discussed this issue with the maintainers of the https://github.com/pointfreeco/swift-case-paths repository (https://github.com/pointfreeco/swift-case-paths/issues/231) and the conclusion was this issue is occurring in the swift-syntax dependency.
### Steps to Reproduce
The following appears to reliably reproduce the issue:
1)
```bash
$ mkdir thebug
$ cd thebug
```
add the following `Dockerfile`:
```Dockerfile
FROM swift:noble
WORKDIR /thebug
RUN git clone --branch 1.7.2 --depth 1 https://github.com/pointfreeco/swift-case-paths .
CMD ["swift", "test", "--jobs", "2"]
```
2) run:
```bash
$ docker build -t thebug . && docker run --rm thebug
```
3) get:
```
error: link command failed with exit code 1 (use -v to see invocation)
/thebug/.build/aarch64-unknown-linux-gnu/debug/CasePathsMacros-tool.build/CasePathableMacro.swift.o:CasePathableMacro.swift.o:$s15CasePathsMacros12SelfRewriterCMf:(.data+0x1358): error: undefined reference to '$s11SwiftSyntax0B8RewriterC14visitationFunc33_F0C5D882E9301122F145EADC4573BFC8LL3forAA0B0VAHcAH_tF'
/thebug/.build/aarch64-unknown-linux-gnu/debug/CasePathsMacros-tool.build/CasePathableMacro.swift.o:CasePathableMacro.swift.o:$s15CasePathsMacros15ElementRewriterCMf:(.data+0x2670): error: undefined reference to '$s11SwiftSyntax0B8RewriterC14visitationFunc33_F0C5D882E9301122F145EADC4573BFC8LL3forAA0B0VAHcAH_tF'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[253/327] Linking CasePathsMacros-tool
error: fatalError
```
0 条评论