Skip to content

Commit a2ee534

Browse files
[Macro] Do not drop in-process-plugin-server-path option
Fix a regression that `in-process-plugin-server-path` is accidentally dropped in explicit module build. rdar://154780122
1 parent f65a248 commit a2ee534

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
@@ -934,6 +934,9 @@ final class CachingBuildTests: XCTestCase {
934934
})
935935
/// command-line that compiles swift should contains -cache-replay-prefix-map
936936
XCTAssertTrue(command.contains { $0 == "-cache-replay-prefix-map" })
937+
if job.kind == .compile {
938+
XCTAssertTrue(command.contains { $0 == "-in-process-plugin-server-path" })
939+
}
937940
XCTAssertFalse(command.contains { $0 == "-plugin-path" || $0 == "-external-plugin-path" ||
938941
$0 == "-load-plugin-library" || $0 == "-load-plugin-executable" })
939942
}

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,6 +2042,14 @@ final class ExplicitModuleBuildTests: XCTestCase {
20422042
var scannerCommand = try driver.dependencyScannerInvocationCommand().1.map { try resolver.resolve($0) }
20432043
XCTAssertTrue(scannerCommand.contains("-plugin-path"))
20442044
XCTAssertTrue(scannerCommand.contains("-external-plugin-path"))
2045+
let jobs = try driver.planBuild()
2046+
for job in jobs {
2047+
if job.kind != .compile {
2048+
continue
2049+
}
2050+
let command = try job.commandLine.map { try resolver.resolve($0) }
2051+
XCTAssertTrue(command.contains { $0 == "-in-process-plugin-server-path" })
2052+
}
20452053
}
20462054
}
20472055

0 commit comments

Comments
 (0)