diff --git a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift index c406f5241..9b7958c6f 100644 --- a/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift +++ b/Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift @@ -566,23 +566,23 @@ extension Driver { .appending(components: frontendTargetInfo.target.triple.platformName() ?? "", "Swift.swiftmodule") let hasToolchainStdlib = try fileSystem.exists(toolchainStdlibPath) - let skipMacroOptions = isPlanJobForExplicitModule && isFrontendArgSupported(.loadResolvedPlugin) + let skipMacroSearchPath = isPlanJobForExplicitModule && isFrontendArgSupported(.loadResolvedPlugin) // If the resource directory has the standard library, prefer the toolchain's plugins // to the platform SDK plugins. // For explicit module build, the resolved plugins are provided by scanner. - if hasToolchainStdlib, !skipMacroOptions { - try addPluginPathArguments(commandLine: &commandLine) + if hasToolchainStdlib { + try addPluginPathArguments(commandLine: &commandLine, skipMacroSearchPath: skipMacroSearchPath) } try toolchain.addPlatformSpecificCommonFrontendOptions(commandLine: &commandLine, inputs: &inputs, frontendTargetInfo: frontendTargetInfo, driver: &self, - skipMacroOptions: skipMacroOptions) + skipMacroOptions: skipMacroSearchPath) // Otherwise, prefer the platform's plugins. - if !hasToolchainStdlib, !skipMacroOptions { - try addPluginPathArguments(commandLine: &commandLine) + if !hasToolchainStdlib { + try addPluginPathArguments(commandLine: &commandLine, skipMacroSearchPath: skipMacroSearchPath) } if let passPluginPath = parsedOptions.getLastArgument(.loadPassPluginEQ), @@ -937,7 +937,7 @@ extension Driver { try explicitDependencyBuildPlanner?.resolveBridgingHeaderDependencies(inputs: &inputs, commandLine: &commandLine) } - mutating func addPluginPathArguments(commandLine: inout [Job.ArgTemplate]) throws { + mutating func addPluginPathArguments(commandLine: inout [Job.ArgTemplate], skipMacroSearchPath: Bool) throws { guard isFrontendArgSupported(.pluginPath) else { return } @@ -952,6 +952,10 @@ extension Driver { #endif } + guard !skipMacroSearchPath else { + return + } + // Default paths for compiler plugins found within the toolchain // (loaded as shared libraries). commandLine.appendFlag(.pluginPath) diff --git a/Tests/SwiftDriverTests/CachingBuildTests.swift b/Tests/SwiftDriverTests/CachingBuildTests.swift index a3603702d..8e197c261 100644 --- a/Tests/SwiftDriverTests/CachingBuildTests.swift +++ b/Tests/SwiftDriverTests/CachingBuildTests.swift @@ -939,6 +939,9 @@ final class CachingBuildTests: XCTestCase { }) /// command-line that compiles swift should contains -cache-replay-prefix-map XCTAssertTrue(command.contains { $0 == "-cache-replay-prefix-map" }) + if job.kind == .compile { + XCTAssertTrue(command.contains { $0 == "-in-process-plugin-server-path" }) + } XCTAssertFalse(command.contains { $0 == "-plugin-path" || $0 == "-external-plugin-path" || $0 == "-load-plugin-library" || $0 == "-load-plugin-executable" }) }