[Explicit Module Builds] Add '-clang-target-variant' flag

https://github.com/swiftlang/swift/pull/37774 added '-clang-target' which allows us to specify a target triple that only differs from '-target' by the OS version, when we want to provide a different OS version for API availability and type-checking, in order to set a common/unified target triple for the entire Clang module dependency graph, for presenting a unified API surface to the Swift client, serving as a maximum type-checking epoch.

This change adds an equivalent flag for the '-target-variant' configuration, as a mechanism to ensure that the entire module dependency graph presents a consistent os version.
This commit is contained in:
Artem Chikin
2025-03-11 13:30:31 -07:00
parent 0997a7e016
commit e96a690cc7
7 changed files with 54 additions and 3 deletions

View File

@@ -1668,6 +1668,15 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
GenericArgs.push_back(triple);
}
if (LangOpts.ClangTargetVariant.has_value()) {
genericSubInvocation.getLangOptions().ClangTargetVariant = LangOpts.ClangTargetVariant;
auto variantTriple = ArgSaver.save(genericSubInvocation.getLangOptions()
.ClangTargetVariant->getTriple());
assert(!variantTriple.empty());
GenericArgs.push_back("-clang-target-variant");
GenericArgs.push_back(variantTriple);
}
// Inherit the target SDK name and version
if (!LangOpts.SDKName.empty()) {
genericSubInvocation.getLangOptions().SDKName = LangOpts.SDKName;