diff --git a/Sources/SWBCore/Settings/Settings.swift b/Sources/SWBCore/Settings/Settings.swift index 1d4b894b..419462df 100644 --- a/Sources/SWBCore/Settings/Settings.swift +++ b/Sources/SWBCore/Settings/Settings.swift @@ -4274,17 +4274,20 @@ private class SettingsBuilder { } let toolchainPath = Path(scope.evaluateAsString(BuiltinMacros.TOOLCHAIN_DIR)) - guard let toolchain = core.toolchainRegistry.toolchains.first(where: { $0.path == toolchainPath }) else { + guard let toolchain = core.toolchainRegistry.toolchains.first(where: { $0.path == toolchainPath }), + let defaultToolchain = core.toolchainRegistry.defaultToolchain + else { return [] } enum ToolchainStyle { - case xcodeDefault + case xcode(isDefault: Bool) case other init(_ toolchain: Toolchain) { - if toolchain.identifier == ToolchainRegistry.defaultToolchainIdentifier { - self = .xcodeDefault + if toolchain.identifier.hasPrefix(ToolchainRegistry.appleToolchainIdentifierPrefix) { + let isDefault = toolchain.identifier == ToolchainRegistry.defaultToolchainIdentifier + self = .xcode(isDefault: isDefault) } else { self = .other } @@ -4293,11 +4296,12 @@ private class SettingsBuilder { let testingPluginsPath = "/usr/lib/swift/host/plugins/testing" switch (ToolchainStyle(toolchain)) { - case .xcodeDefault: - // This target is building using the same toolchain as the one used - // to build the testing libraries which it is using, so it can use - // non-external plugin flags. - return ["-plugin-path", "$(TOOLCHAIN_DIR)\(testingPluginsPath)"] + case let .xcode(isDefault): + // This target is using a built-in Xcode toolchain, and that should + // match the toolchain which was used to build the testing libraries + // this target is using, so it can use non-external plugin flags. + let toolchainPathPrefix = isDefault ? "$(TOOLCHAIN_DIR)" : defaultToolchain.path.str + return ["-plugin-path", "\(toolchainPathPrefix)\(testingPluginsPath)"] case .other: // This target is using the testing libraries from Xcode, // which were built using the XcodeDefault toolchain, but it's using