Skip to content

Commit 6f87ef9

Browse files
committed
Fix linking error on linux
- libstdc++ needs to be added when linking if any dependency has a cpp dependency
1 parent 04b0249 commit 6f87ef9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Sources/SwiftBuildSupport/PackagePIFProjectBuilder+Modules.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ extension PackagePIFProjectBuilder {
499499
for platform in ProjectModel.BuildSettings.Platform.allCases {
500500
// darwin & freebsd
501501
if [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .xrOS, .driverKit, .freebsd].contains(platform) {
502-
settings[.OTHER_LDFLAGS, platform] = ["-lc++", "$(inherited)"]
502+
impartedSettings[.OTHER_LDFLAGS, platform] = ["-lc++", "$(inherited)"]
503503
} else if [.android, .linux, .wasi, .openbsd].contains(platform) {
504-
settings[.OTHER_LDFLAGS, platform] = ["-lstdc++", "$(inherited)"]
504+
impartedSettings[.OTHER_LDFLAGS, platform] = ["-lstdc++", "$(inherited)"]
505505
}
506506
}
507507
}

Tests/SwiftBuildSupportTests/PIFBuilderTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ struct PIFBuilderTests {
163163
.buildConfig(named: "Release")
164164

165165
for platform in ProjectModel.BuildSettings.Platform.allCases {
166-
let ld_flags = releaseConfig.settings[.OTHER_LDFLAGS, platform]
166+
let ld_flags = releaseConfig.impartedBuildProperties.settings[.OTHER_LDFLAGS, platform]
167167
if [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .xrOS, .driverKit, .freebsd].contains(platform) {
168168
#expect(ld_flags == ["-lc++", "$(inherited)"], "for platform \(platform)")
169169
} else if [.android, .linux, .wasi, .openbsd].contains(platform) {

0 commit comments

Comments
 (0)