Skip to content

Commit 8b1cfc9

Browse files
authored
Swift Build: Adopt LINKER_DRIVER=auto in PIF (#8884)
1 parent 3cdae8e commit 8b1cfc9

File tree

9 files changed

+253
-298
lines changed

9 files changed

+253
-298
lines changed

Sources/SwiftBuildSupport/PackagePIFBuilder.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,9 @@ public final class PackagePIFBuilder {
558558
// sharing.
559559
settings[.COMPILER_WORKING_DIRECTORY] = "$(WORKSPACE_DIR)"
560560

561+
// Defer to the build system for linker driver selection.
562+
settings[.LINKER_DRIVER] = "auto"
563+
561564
// Hook to customize the project-wide build settings.
562565
self.delegate.configureProjectBuildSettings(&settings)
563566

Tests/CommandsTests/PackageCommandTests.swift

Lines changed: 230 additions & 245 deletions
Large diffs are not rendered by default.

Tests/CommandsTests/RunCommandTests.swift

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ struct RunCommandTests {
170170
} when: {
171171
(.windows == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild)
172172
|| (.windows == ProcessInfo.hostOperatingSystem && buildSystem == .native && CiEnvironment.runningInSmokeTestPipeline)
173-
|| (.linux == ProcessInfo.hostOperatingSystem && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
174173
}
175174
}
176175

@@ -231,7 +230,7 @@ struct RunCommandTests {
231230
#expect(runOutput.contains("2"))
232231
}
233232
} when: {
234-
([.windows, .linux].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
233+
([.windows].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
235234
|| (.windows == ProcessInfo.hostOperatingSystem && [.native, .swiftbuild].contains(buildSystem) && CiEnvironment.runningInSmokeTestPipeline)
236235
}
237236
}
@@ -253,7 +252,6 @@ struct RunCommandTests {
253252
}
254253
} when: {
255254
(ProcessInfo.hostOperatingSystem == .windows && CiEnvironment.runningInSmokeTestPipeline && [.native, .swiftbuild].contains(buildSystem))
256-
|| (ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild && CiEnvironment.runningInSelfHostedPipeline)
257255
}
258256
}
259257

@@ -425,12 +423,7 @@ struct RunCommandTests {
425423
#expect(stdout == "done\n")
426424
}
427425
} when: {
428-
(
429-
ProcessInfo.hostOperatingSystem == .linux &&
430-
buildSystem == .swiftbuild &&
431-
CiEnvironment.runningInSelfHostedPipeline
432-
)
433-
|| (CiEnvironment.runningInSmokeTestPipeline && ProcessInfo.hostOperatingSystem == .windows)
426+
(CiEnvironment.runningInSmokeTestPipeline && ProcessInfo.hostOperatingSystem == .windows)
434427
}
435428
}
436429

Tests/CommandsTests/TestCommandTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,8 @@ struct TestCommandTests {
242242
#expect(result.stderr.contains("-enable-testing"))
243243
}
244244
} when: {
245-
(buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem)
246245
// || (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline)
247-
|| (buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem )
246+
(buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem )
248247
}
249248
}
250249

@@ -301,7 +300,6 @@ struct TestCommandTests {
301300
}
302301
} when: {
303302
(buildSystem == .swiftbuild && .windows == ProcessInfo.hostOperatingSystem)
304-
|| (buildSystem == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline)
305303
}
306304
}
307305

Tests/FunctionalTests/DependencyResolutionTests.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ struct DependencyResolutionTests {
5656
#expect(output == "Foo\nBar\n")
5757
}
5858
} when: {
59-
(ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild && !CiEnvironment.runningInSmokeTestPipeline)
60-
|| (ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild)
59+
(ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild)
6160
}
6261
}
6362

@@ -116,8 +115,7 @@ struct DependencyResolutionTests {
116115
#expect(output == "meiow Baz\n")
117116
}
118117
} when: {
119-
(ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild && !CiEnvironment.runningInSmokeTestPipeline)
120-
|| (ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild)
118+
(ProcessInfo.hostOperatingSystem == .windows && buildSystem == .swiftbuild)
121119
}
122120
}
123121

@@ -191,8 +189,7 @@ struct DependencyResolutionTests {
191189
#expect(output == "♣︎K\n♣︎Q\n♣︎J\n♣︎10\n♣︎9\n♣︎8\n♣︎7\n♣︎6\n♣︎5\n♣︎4\n")
192190
}
193191
} when: {
194-
([.linux, .windows].contains(ProcessInfo.hostOperatingSystem) && buildSystem == .swiftbuild)
195-
|| (ProcessInfo.hostOperatingSystem == .windows) // due to long path isues
192+
ProcessInfo.hostOperatingSystem == .windows // due to long path isues
196193
}
197194
}
198195

Tests/FunctionalTests/PluginTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ final class PluginTests {
6363
)
6464
#expect(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
6565
}
66-
} when: { ProcessInfo.hostOperatingSystem == .linux || ProcessInfo.hostOperatingSystem == .windows }
66+
} when: { ProcessInfo.hostOperatingSystem == .windows }
6767
}
6868

6969
@Test(
@@ -316,7 +316,7 @@ final class PluginTests {
316316
)
317317
#expect(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
318318
}
319-
} when: { ProcessInfo.hostOperatingSystem == .windows || ProcessInfo.hostOperatingSystem == .linux }
319+
} when: { ProcessInfo.hostOperatingSystem == .windows }
320320
}
321321

322322
@Test(
@@ -1662,7 +1662,7 @@ final class PluginTests {
16621662
#expect(stderr.contains("Creating foo.swift from foo.dat"), "stdout:\n\(stdout)\nstderr:\n\(stderr)")
16631663
#expect(stdout.contains("Build complete!"), "stdout:\n\(stdout)\nstderr:\n\(stderr)")
16641664
}
1665-
} when: { ProcessInfo.hostOperatingSystem == .windows || ProcessInfo.hostOperatingSystem == .linux }
1665+
} when: { ProcessInfo.hostOperatingSystem == .windows }
16661666
}
16671667

16681668
@Test(
@@ -1694,7 +1694,7 @@ final class PluginTests {
16941694
)
16951695
#expect(stdout.contains("Build complete!"), "stdout:\n\(stdout)")
16961696
}
1697-
} when: { ProcessInfo.hostOperatingSystem == .linux || ProcessInfo.hostOperatingSystem == .windows }
1697+
} when: { ProcessInfo.hostOperatingSystem == .windows }
16981698
}
16991699

17001700
@Test(

Tests/FunctionalTests/ToolsVersionTests.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,9 @@ struct ToolsVersionTests {
127127
let binPath = try primaryPath.appending(components: buildSystem.binPath(for: configuration))
128128
let exe: String = binPath.appending(components: "Primary").pathString
129129
// v1 should get selected because v1.0.1 depends on a (way) higher set of tools.
130-
try await withKnownIssue {
131-
let executableActualOutput = try await AsyncProcess.checkNonZeroExit(args: exe).spm_chomp()
132-
#expect(executableActualOutput == "[email protected]")
133-
} when: {
134-
ProcessInfo.hostOperatingSystem == .linux && buildSystem == .swiftbuild && !CiEnvironment.runningInSmokeTestPipeline
135-
}
130+
let executableActualOutput = try await AsyncProcess.checkNonZeroExit(args: exe).spm_chomp()
131+
#expect(executableActualOutput == "[email protected]")
132+
136133

137134
// Set the tools version to something high.
138135
_ = try await executeSwiftPackage(

Tests/FunctionalTests/TraitTests.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ struct TraitTests {
120120
}
121121
} when: {
122122
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
123-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
124123
}
125124
}
126125

@@ -171,7 +170,6 @@ struct TraitTests {
171170
}
172171
} when: {
173172
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
174-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
175173
}
176174
}
177175

@@ -226,7 +224,6 @@ struct TraitTests {
226224
}
227225
} when: {
228226
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
229-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
230227
}
231228
}
232229

@@ -268,7 +265,6 @@ struct TraitTests {
268265
}
269266
} when: {
270267
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
271-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
272268
}
273269
}
274270

@@ -315,7 +311,6 @@ struct TraitTests {
315311
}
316312
} when: {
317313
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
318-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
319314
}
320315
}
321316

@@ -373,7 +368,6 @@ struct TraitTests {
373368
}
374369
} when: {
375370
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
376-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
377371
}
378372
}
379373

@@ -434,7 +428,6 @@ struct TraitTests {
434428
}
435429
} when: {
436430
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || buildSystem == .swiftbuild))
437-
|| (buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
438431
}
439432
}
440433

@@ -733,7 +726,6 @@ struct TraitTests {
733726
}
734727
} when: {
735728
(ProcessInfo.hostOperatingSystem == .windows && (CiEnvironment.runningInSmokeTestPipeline || data.buildSystem == .swiftbuild))
736-
|| (data.buildSystem == .swiftbuild && ProcessInfo.hostOperatingSystem == .linux && CiEnvironment.runningInSelfHostedPipeline)
737729
}
738730
}
739731
}

Tests/IntegrationTests/SwiftPMTests.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,23 +107,13 @@ private struct SwiftPMTests {
107107
buildSystem: buildSystemProvider,
108108
)
109109

110-
try await withKnownIssue(
111-
"Error while loading shared libraries: libswiftCore.so: cannot open shared object file: No such file or directory"
112-
) {
113-
// The 'native' build system uses 'swiftc' as the linker driver, which adds an RUNPATH to the swift
114-
// runtime libraries in the SDK.
115-
// 'swiftbuild' directly calls clang, which does not add the extra RUNPATH, so runtime libraries cannot
116-
// be found.
117-
let runOutput = try await executeSwiftRun(
118-
packagePath,
119-
nil,
120-
buildSystem: buildSystemProvider,
121-
)
122-
#expect(!runOutput.stderr.contains("error:"))
123-
#expect(runOutput.stdout.contains("Hello, world!"))
124-
} when: {
125-
(buildSystemProvider == .swiftbuild && .linux == ProcessInfo.hostOperatingSystem && CiEnvironment.runningInSelfHostedPipeline)
126-
}
110+
let runOutput = try await executeSwiftRun(
111+
packagePath,
112+
nil,
113+
buildSystem: buildSystemProvider,
114+
)
115+
#expect(!runOutput.stderr.contains("error:"))
116+
#expect(runOutput.stdout.contains("Hello, world!"))
127117
}
128118
}
129119

0 commit comments

Comments
 (0)