mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Frontend: Fix -target-variant subarch normalization.
In https://github.com/swiftlang/swift/pull/77156, normalization was introduced for -target-variant triples. That PR also caused -target-variant arguments to be inherited from the main compilation options whenever building dependency modules from their interfaces, which is incorrect. The -target-variant option must only be specified when compiling a "zippered" module, but the dependencies of zippered modules are not necessarily zippered themselves and indiscriminantly propagating the option can cause miscompilation. The new, more targeted approach to normalizing arm64e triples simply uses the arch and subarch of the -target argument of the main compile to decide whether the subarch of both the -target and -target-variant arguments of a dependency need adjustment. Resolves rdar://135322077 and rdar://141640919.
This commit is contained in:
@@ -1513,8 +1513,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
|
||||
static bool readSwiftInterfaceVersionAndArgs(
|
||||
SourceManager &SM, DiagnosticEngine &Diags, llvm::StringSaver &ArgSaver,
|
||||
SwiftInterfaceInfo &interfaceInfo, StringRef interfacePath,
|
||||
SourceLoc diagnosticLoc, llvm::Triple preferredTarget,
|
||||
std::optional<llvm::Triple> preferredTargetVariant) {
|
||||
SourceLoc diagnosticLoc, llvm::Triple preferredTarget) {
|
||||
llvm::vfs::FileSystem &fs = *SM.getFileSystem();
|
||||
auto FileOrError = swift::vfs::getFileOrSTDIN(fs, interfacePath);
|
||||
if (!FileOrError) {
|
||||
@@ -1538,8 +1537,7 @@ static bool readSwiftInterfaceVersionAndArgs(
|
||||
|
||||
if (extractCompilerFlagsFromInterface(interfacePath, SB, ArgSaver,
|
||||
interfaceInfo.Arguments,
|
||||
preferredTarget,
|
||||
preferredTargetVariant)) {
|
||||
preferredTarget)) {
|
||||
InterfaceSubContextDelegateImpl::diagnose(
|
||||
interfacePath, diagnosticLoc, SM, &Diags,
|
||||
diag::error_extracting_version_from_module_interface);
|
||||
@@ -1623,8 +1621,7 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
|
||||
readSwiftInterfaceVersionAndArgs(
|
||||
Instance.getSourceMgr(), Instance.getDiags(), ArgSaver, InterfaceInfo,
|
||||
interfacePath, SourceLoc(),
|
||||
Instance.getInvocation().getLangOptions().Target,
|
||||
Instance.getInvocation().getLangOptions().TargetVariant);
|
||||
Instance.getInvocation().getLangOptions().Target);
|
||||
|
||||
auto Builder = ExplicitModuleInterfaceBuilder(
|
||||
Instance, &Instance.getDiags(), Instance.getSourceMgr(),
|
||||
@@ -1673,15 +1670,6 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
|
||||
GenericArgs.push_back(triple);
|
||||
}
|
||||
|
||||
if (LangOpts.TargetVariant.has_value()) {
|
||||
genericSubInvocation.getLangOptions().TargetVariant = LangOpts.TargetVariant;
|
||||
auto variantTriple = ArgSaver.save(genericSubInvocation.getLangOptions().TargetVariant->str());
|
||||
if (!variantTriple.empty()) {
|
||||
GenericArgs.push_back("-target-variant");
|
||||
GenericArgs.push_back(variantTriple);
|
||||
}
|
||||
}
|
||||
|
||||
// Inherit the target SDK name and version
|
||||
if (!LangOpts.SDKName.empty()) {
|
||||
genericSubInvocation.getLangOptions().SDKName = LangOpts.SDKName;
|
||||
@@ -1821,8 +1809,7 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
|
||||
StringRef interfacePath, SourceLoc diagnosticLoc) {
|
||||
if (readSwiftInterfaceVersionAndArgs(SM, *Diags, ArgSaver, interfaceInfo,
|
||||
interfacePath, diagnosticLoc,
|
||||
subInvocation.getLangOptions().Target,
|
||||
subInvocation.getLangOptions().TargetVariant))
|
||||
subInvocation.getLangOptions().Target))
|
||||
return true;
|
||||
|
||||
// Prior to Swift 5.9, swiftinterfaces were always built (accidentally) with
|
||||
|
||||
Reference in New Issue
Block a user