mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: allow specifying a different target triple for internal clang instance to use
Before this change, we always use the Swift target triple to instantiate the internal Clang instance. When loading a Swift module from the textual interface, we may pick up a lower target triple to use to build the Swift module because the target is hard-coded in the textual interface file. This implies we may end up building multiple versions of the same Clang module, one for each target triple of the loading Swift module. This change adds a new frontend flag -clang-target to allow clients to specify a consistent clang target to use across the Swift module boundaries. This value won't change because it's not part of .swiftinterface files. swift-driver should pass down -clang-target for each frontend invocation, and its value should be identical to -target. Related to: rdar://72480261
This commit is contained in:
@@ -1269,6 +1269,17 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
|
||||
GenericArgs.push_back(triple);
|
||||
}
|
||||
|
||||
if (LangOpts.ClangTarget.hasValue()) {
|
||||
genericSubInvocation.getLangOptions().ClangTarget = LangOpts.ClangTarget;
|
||||
auto triple = ArgSaver.save(genericSubInvocation.getLangOptions()
|
||||
.ClangTarget->getTriple());
|
||||
assert(!triple.empty());
|
||||
// In explicit module build, all PCMs will be built using the given clang target.
|
||||
// So the Swift interface should know that as well to load these PCMs properly.
|
||||
GenericArgs.push_back("-clang-target");
|
||||
GenericArgs.push_back(triple);
|
||||
}
|
||||
|
||||
// Inherit the Swift language version
|
||||
genericSubInvocation.getLangOptions().EffectiveLanguageVersion =
|
||||
LangOpts.EffectiveLanguageVersion;
|
||||
|
||||
Reference in New Issue
Block a user