@@ -473,21 +473,24 @@ extension Driver {
473
473
commandLine. appendFlag ( $0)
474
474
}
475
475
476
+ let toolchainStdlibPath = VirtualPath . lookup ( frontendTargetInfo. runtimeResourcePath. path)
477
+ . appending ( components: frontendTargetInfo. target. triple. platformName ( ) ?? " " , " Swift.swiftmodule " )
478
+ let hasToolchainStdlib = try fileSystem. exists ( toolchainStdlibPath)
479
+
480
+ // If the resource directory has the standard library, prefer the toolchain's plugins
481
+ // to the platform SDK plugins.
482
+ if hasToolchainStdlib {
483
+ try addPluginPathArguments ( commandLine: & commandLine)
484
+ }
485
+
476
486
try toolchain. addPlatformSpecificCommonFrontendOptions ( commandLine: & commandLine,
477
487
inputs: & inputs,
478
488
frontendTargetInfo: frontendTargetInfo,
479
489
driver: & self )
480
490
481
- // Platform-agnostic options that need to happen after platform-specific ones.
482
- if isFrontendArgSupported ( . pluginPath) {
483
- // Default paths for compiler plugins found within the toolchain
484
- // (loaded as shared libraries).
485
- let pluginPathRoot = VirtualPath . absolute ( try toolchain. executableDir. parentDirectory)
486
- commandLine. appendFlag ( . pluginPath)
487
- commandLine. appendPath ( pluginPathRoot. pluginPath)
488
-
489
- commandLine. appendFlag ( . pluginPath)
490
- commandLine. appendPath ( pluginPathRoot. localPluginPath)
491
+ // Otherwise, prefer the platform's plugins.
492
+ if !hasToolchainStdlib {
493
+ try addPluginPathArguments ( commandLine: & commandLine)
491
494
}
492
495
}
493
496
@@ -774,6 +777,22 @@ extension Driver {
774
777
try explicitDependencyBuildPlanner? . resolveBridgingHeaderDependencies ( inputs: & inputs, commandLine: & commandLine)
775
778
}
776
779
780
+ mutating func addPluginPathArguments( commandLine: inout [ Job . ArgTemplate ] ) throws {
781
+ guard isFrontendArgSupported ( . pluginPath) else {
782
+ return
783
+ }
784
+
785
+ // Default paths for compiler plugins found within the toolchain
786
+ // (loaded as shared libraries).
787
+ let pluginPathRoot = VirtualPath . absolute ( try toolchain. executableDir. parentDirectory)
788
+ commandLine. appendFlag ( . pluginPath)
789
+ commandLine. appendPath ( pluginPathRoot. pluginPath)
790
+
791
+ commandLine. appendFlag ( . pluginPath)
792
+ commandLine. appendPath ( pluginPathRoot. localPluginPath)
793
+ }
794
+
795
+
777
796
/// If explicit dependency planner supports creating bridging header pch command.
778
797
public func supportsBridgingHeaderPCHCommand( ) throws -> Bool {
779
798
return try explicitDependencyBuildPlanner? . supportsBridgingHeaderPCHCommand ( ) ?? false
0 commit comments