[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

@@ -1433,9 +1433,10 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
// necessary because the textual interface hardcoded the proper target triple
// to use. Inferring -clang-target there will always give us the default
// target triple.
if (const Arg *A = Args.getLastArg(OPT_clang_target)) {
if (const Arg *A = Args.getLastArg(OPT_clang_target))
Opts.ClangTarget = llvm::Triple(A->getValue());
}
if (const Arg *A = Args.getLastArg(OPT_clang_target_variant))
Opts.ClangTargetVariant = llvm::Triple(A->getValue());
Opts.setCxxInteropFromArgs(Args, Diags);