@@ -84,12 +84,13 @@ extension Driver {
8484 break
8585 }
8686
87+ let isPlanJobForExplicitModule = parsedOptions. contains ( . driverExplicitModuleBuild) &&
88+ moduleDependencyGraphUse == . computed
8789 let jobNeedPathRemap : Bool
8890 // If in ExplicitModuleBuild mode and the dependency graph has been computed, add module
8991 // dependencies.
9092 // May also be used for generation of the dependency graph itself in ExplicitModuleBuild mode.
91- if ( parsedOptions. contains ( . driverExplicitModuleBuild) &&
92- moduleDependencyGraphUse == . computed) {
93+ if isPlanJobForExplicitModule {
9394 switch kind {
9495 case . generatePCH:
9596 try addExplicitPCHBuildArguments ( inputs: & inputs, commandLine: & commandLine)
@@ -344,10 +345,12 @@ extension Driver {
344345 }
345346
346347 // Emit user-provided plugin paths, in order.
347- if isFrontendArgSupported ( . externalPluginPath) {
348- try commandLine. appendAll ( . pluginPath, . externalPluginPath, . loadPluginLibrary, . loadPluginExecutable, from: & parsedOptions)
349- } else if isFrontendArgSupported ( . pluginPath) {
350- try commandLine. appendAll ( . pluginPath, . loadPluginLibrary, from: & parsedOptions)
348+ if !isPlanJobForExplicitModule {
349+ if isFrontendArgSupported ( . externalPluginPath) {
350+ try commandLine. appendAll ( . pluginPath, . externalPluginPath, . loadPluginLibrary, . loadPluginExecutable, from: & parsedOptions)
351+ } else if isFrontendArgSupported ( . pluginPath) {
352+ try commandLine. appendAll ( . pluginPath, . loadPluginLibrary, from: & parsedOptions)
353+ }
351354 }
352355
353356 if isFrontendArgSupported ( . blockListFile) {
@@ -563,19 +566,22 @@ extension Driver {
563566 . appending ( components: frontendTargetInfo. target. triple. platformName ( ) ?? " " , " Swift.swiftmodule " )
564567 let hasToolchainStdlib = try fileSystem. exists ( toolchainStdlibPath)
565568
569+ let skipMacroOptions = isPlanJobForExplicitModule && isFrontendArgSupported ( . loadResolvedPlugin)
566570 // If the resource directory has the standard library, prefer the toolchain's plugins
567571 // to the platform SDK plugins.
568- if hasToolchainStdlib {
572+ // For explicit module build, the resolved plugins are provided by scanner.
573+ if hasToolchainStdlib, !skipMacroOptions {
569574 try addPluginPathArguments ( commandLine: & commandLine)
570575 }
571576
572577 try toolchain. addPlatformSpecificCommonFrontendOptions ( commandLine: & commandLine,
573578 inputs: & inputs,
574579 frontendTargetInfo: frontendTargetInfo,
575- driver: & self )
580+ driver: & self ,
581+ skipMacroOptions: skipMacroOptions)
576582
577583 // Otherwise, prefer the platform's plugins.
578- if !hasToolchainStdlib {
584+ if !hasToolchainStdlib, !skipMacroOptions {
579585 try addPluginPathArguments ( commandLine: & commandLine)
580586 }
581587
0 commit comments