Skip to content

Commit 5f199e8

Browse files
Merge pull request #1947 from cachemeifyoucan/eng/PR-154780122
[Macro] Do not drop `in-process-plugin-server-path` option
2 parents def5462 + a2ee534 commit 5f199e8

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -566,23 +566,23 @@ extension Driver {
566566
.appending(components: frontendTargetInfo.target.triple.platformName() ?? "", "Swift.swiftmodule")
567567
let hasToolchainStdlib = try fileSystem.exists(toolchainStdlibPath)
568568

569-
let skipMacroOptions = isPlanJobForExplicitModule && isFrontendArgSupported(.loadResolvedPlugin)
569+
let skipMacroSearchPath = isPlanJobForExplicitModule && isFrontendArgSupported(.loadResolvedPlugin)
570570
// If the resource directory has the standard library, prefer the toolchain's plugins
571571
// to the platform SDK plugins.
572572
// For explicit module build, the resolved plugins are provided by scanner.
573-
if hasToolchainStdlib, !skipMacroOptions {
574-
try addPluginPathArguments(commandLine: &commandLine)
573+
if hasToolchainStdlib {
574+
try addPluginPathArguments(commandLine: &commandLine, skipMacroSearchPath: skipMacroSearchPath)
575575
}
576576

577577
try toolchain.addPlatformSpecificCommonFrontendOptions(commandLine: &commandLine,
578578
inputs: &inputs,
579579
frontendTargetInfo: frontendTargetInfo,
580580
driver: &self,
581-
skipMacroOptions: skipMacroOptions)
581+
skipMacroOptions: skipMacroSearchPath)
582582

583583
// Otherwise, prefer the platform's plugins.
584-
if !hasToolchainStdlib, !skipMacroOptions {
585-
try addPluginPathArguments(commandLine: &commandLine)
584+
if !hasToolchainStdlib {
585+
try addPluginPathArguments(commandLine: &commandLine, skipMacroSearchPath: skipMacroSearchPath)
586586
}
587587

588588
if let passPluginPath = parsedOptions.getLastArgument(.loadPassPluginEQ),
@@ -923,7 +923,7 @@ extension Driver {
923923
entries[inputEntry, default: [:]][output.type] = output.fileHandle
924924
}
925925

926-
mutating func addPluginPathArguments(commandLine: inout [Job.ArgTemplate]) throws {
926+
mutating func addPluginPathArguments(commandLine: inout [Job.ArgTemplate], skipMacroSearchPath: Bool) throws {
927927
guard isFrontendArgSupported(.pluginPath) else {
928928
return
929929
}
@@ -938,6 +938,10 @@ extension Driver {
938938
#endif
939939
}
940940

941+
guard !skipMacroSearchPath else {
942+
return
943+
}
944+
941945
// Default paths for compiler plugins found within the toolchain
942946
// (loaded as shared libraries).
943947
commandLine.appendFlag(.pluginPath)

Tests/SwiftDriverTests/CachingBuildTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,9 @@ final class CachingBuildTests: XCTestCase {
924924
})
925925
/// command-line that compiles swift should contains -cache-replay-prefix-map
926926
XCTAssertTrue(command.contains { $0 == "-cache-replay-prefix-map" })
927+
if job.kind == .compile {
928+
XCTAssertTrue(command.contains { $0 == "-in-process-plugin-server-path" })
929+
}
927930
XCTAssertFalse(command.contains { $0 == "-plugin-path" || $0 == "-external-plugin-path" ||
928931
$0 == "-load-plugin-library" || $0 == "-load-plugin-executable" })
929932
}

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,6 +2026,14 @@ final class ExplicitModuleBuildTests: XCTestCase {
20262026
let scannerCommand = try driver.dependencyScannerInvocationCommand().1.map { try resolver.resolve($0) }
20272027
XCTAssertTrue(scannerCommand.contains("-plugin-path"))
20282028
XCTAssertTrue(scannerCommand.contains("-external-plugin-path"))
2029+
let jobs = try driver.planBuild()
2030+
for job in jobs {
2031+
if job.kind != .compile {
2032+
continue
2033+
}
2034+
let command = try job.commandLine.map { try resolver.resolve($0) }
2035+
XCTAssertTrue(command.contains { $0 == "-in-process-plugin-server-path" })
2036+
}
20292037
}
20302038
}
20312039

0 commit comments

Comments
 (0)