Build fails in release with: ld: Undefined symbols: static (extension in SystemPackage):SystemPackage._StrSlice.== infix(A, A) -> Swift.Bool
- Dominant language
- Swift
- Stars
- 1.4k
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
Any package which depends on `swift-system` and uses the `==` on `FilePath.Component` will fail to build _in release mode_ (debug is fine).
Consider this example program
```swift
import SystemPackage
print(FilePath("/x").lastComponent! == FilePath("/x").lastComponent!)
```
with the following dependencies/targets
```
dependencies: [
.package(url: "https://github.com/apple/swift-system.git", from: "1.0.0"),
],
targets: [
.executableTarget(
name: "repro",
dependencies: [
.product(name: "SystemPackage", package: "swift-system"),
]
),
]
```
debug works
```
$ swift run
Building for debugging...
Build complete! (0.34s)
true
```
release fails
```
$ swift run -c release
Building for production...
error: link command failed with exit code 1 (use -v to see invocation)
ld: Undefined symbols:
static (extension in SystemPackage):SystemPackage._StrSlice.== infix(A, A) -> Swift.Bool, referenced from:
_repro_main in main.swift.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: fatalError
[0/1] Linking repro
```
Also reproes in Xcode.
This is Xcode 15A221 but also reproduces on anything else I tried.
Contributor guide
Research direction
Start with the minimal Swift program using SystemPackage and FilePath.Component equality, then reproduce the failure with `swift run -c release` and compare it with the successful debug build. Trace the release link failure for `SystemPackage._StrSlice.==` and verify that the example builds and runs successfully in release mode, including in Xcode if applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100