Skip to content

Commit cea7c11

Browse files
committed
Put PLATFORM_DIR plugin paths before SDK-path-derived paths
Since PLATFORM_DIR is the override, put it before the default-derived path.
1 parent d3e2eef commit cea7c11

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Sources/SwiftDriver/Toolchains/DarwinToolchain.swift

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -456,24 +456,25 @@ public final class DarwinToolchain: Toolchain {
456456
}
457457

458458
if driver.isFrontendArgSupported(.externalPluginPath) {
459-
// Determine the platform path based on the SDK path.
460-
addPluginPaths(
461-
forPlatform: VirtualPath.lookup(sdkPath)
462-
.parentDirectory
463-
.parentDirectory
464-
.parentDirectory,
465-
commandLine: &commandLine
466-
)
467-
468459
// If the PLATFORM_DIR environment variable is set, also add plugin
469-
// paths into it.
460+
// paths into it. Since this is a user override, it comes beore the
461+
// default platform path that's based on the SDK.
470462
if let platformDir = env["PLATFORM_DIR"],
471463
let platformPath = try? VirtualPath(path: platformDir) {
472464
addPluginPaths(
473465
forPlatform: platformPath,
474466
commandLine: &commandLine
475467
)
476468
}
469+
470+
// Determine the platform path based on the SDK path.
471+
addPluginPaths(
472+
forPlatform: VirtualPath.lookup(sdkPath)
473+
.parentDirectory
474+
.parentDirectory
475+
.parentDirectory,
476+
commandLine: &commandLine
477+
)
477478
}
478479
}
479480

Tests/SwiftDriverTests/SwiftDriverTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7805,7 +7805,7 @@ final class SwiftDriverTests: XCTestCase {
78057805
XCTAssertNotNil(envPlatformPluginPathIndex)
78067806

78077807
if let platformPluginPathIndex, let envPlatformPluginPathIndex {
7808-
XCTAssertLessThan(platformPluginPathIndex, envPlatformPluginPathIndex)
7808+
XCTAssertLessThan(envPlatformPluginPathIndex, platformPluginPathIndex)
78097809
}
78107810

78117811
let toolchainPluginPathIndex = job.commandLine.firstIndex(of: .path(.absolute(try driver.toolchain.executableDir.parentDirectory.appending(components: "lib", "swift", "host", "plugins"))))

0 commit comments

Comments
 (0)