@@ -1433,12 +1433,10 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
14331433 SearchPathOpts.CandidateCompiledModules );
14341434}
14351435
1436- static bool readSwiftInterfaceVersionAndArgs (SourceManager &SM,
1437- DiagnosticEngine &Diags,
1438- llvm::StringSaver &ArgSaver,
1439- SwiftInterfaceInfo &interfaceInfo,
1440- StringRef interfacePath,
1441- SourceLoc diagnosticLoc) {
1436+ static bool readSwiftInterfaceVersionAndArgs (
1437+ SourceManager &SM, DiagnosticEngine &Diags, llvm::StringSaver &ArgSaver,
1438+ SwiftInterfaceInfo &interfaceInfo, StringRef interfacePath,
1439+ SourceLoc diagnosticLoc, llvm::Triple preferredTarget) {
14421440 llvm::vfs::FileSystem &fs = *SM.getFileSystem ();
14431441 auto FileOrError = swift::vfs::getFileOrSTDIN (fs, interfacePath);
14441442 if (!FileOrError) {
@@ -1461,7 +1459,8 @@ static bool readSwiftInterfaceVersionAndArgs(SourceManager &SM,
14611459 }
14621460
14631461 if (extractCompilerFlagsFromInterface (interfacePath, SB, ArgSaver,
1464- interfaceInfo.Arguments )) {
1462+ interfaceInfo.Arguments ,
1463+ preferredTarget)) {
14651464 InterfaceSubContextDelegateImpl::diagnose (
14661465 interfacePath, diagnosticLoc, SM, &Diags,
14671466 diag::error_extracting_version_from_module_interface);
@@ -1543,9 +1542,10 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
15431542 llvm::BumpPtrAllocator alloc;
15441543 llvm::StringSaver ArgSaver (alloc);
15451544 SwiftInterfaceInfo InterfaceInfo;
1546- readSwiftInterfaceVersionAndArgs (Instance.getSourceMgr (), Instance.getDiags (),
1547- ArgSaver, InterfaceInfo, interfacePath,
1548- SourceLoc ());
1545+ readSwiftInterfaceVersionAndArgs (
1546+ Instance.getSourceMgr (), Instance.getDiags (), ArgSaver, InterfaceInfo,
1547+ interfacePath, SourceLoc (),
1548+ Instance.getInvocation ().getLangOptions ().Target );
15491549
15501550 auto Builder = ExplicitModuleInterfaceBuilder (
15511551 Instance, &Instance.getDiags (), Instance.getSourceMgr (),
@@ -1707,7 +1707,8 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
17071707 CompilerInvocation &subInvocation, SwiftInterfaceInfo &interfaceInfo,
17081708 StringRef interfacePath, SourceLoc diagnosticLoc) {
17091709 if (readSwiftInterfaceVersionAndArgs (SM, *Diags, ArgSaver, interfaceInfo,
1710- interfacePath, diagnosticLoc))
1710+ interfacePath, diagnosticLoc,
1711+ subInvocation.getLangOptions ().Target ))
17111712 return true ;
17121713
17131714 // Prior to Swift 5.9, swiftinterfaces were always built (accidentally) with
@@ -1795,9 +1796,6 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
17951796 GenericArgs.push_back (" -application-extension" );
17961797 }
17971798
1798- // Save the parent invocation's Target Triple
1799- ParentInvocationTarget = langOpts.Target ;
1800-
18011799 // Pass down -explicit-swift-module-map-file
18021800 StringRef explicitSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
18031801 genericSubInvocation.getSearchPathOptions ().ExplicitSwiftModuleMap =
@@ -2060,31 +2058,6 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
20602058 BuildArgs.insert (BuildArgs.end (), interfaceInfo.Arguments .begin (),
20612059 interfaceInfo.Arguments .end ());
20622060
2063- // If the target triple parsed from the Swift interface file differs
2064- // only in subarchitecture from the original target triple, then
2065- // we have loaded a Swift interface from a different-but-compatible
2066- // architecture slice. Use the original subarchitecture.
2067- llvm::Triple parsedTargetTriple (subInvocation.getTargetTriple ());
2068- if (parsedTargetTriple.getSubArch () != originalTargetTriple.getSubArch () &&
2069- parsedTargetTriple.getArch () == originalTargetTriple.getArch () &&
2070- parsedTargetTriple.getVendor () == originalTargetTriple.getVendor () &&
2071- parsedTargetTriple.getOS () == originalTargetTriple.getOS () &&
2072- parsedTargetTriple.getEnvironment ()
2073- == originalTargetTriple.getEnvironment ()) {
2074- parsedTargetTriple.setArchName (originalTargetTriple.getArchName ());
2075- subInvocation.setTargetTriple (parsedTargetTriple.str ());
2076- }
2077-
2078- // Find and overload all "-target" to be parsedTargetTriple. This make sure
2079- // the build command for the interface is the same no matter what the parent
2080- // triple is so there is no need to spawn identical jobs.
2081- assert (llvm::find (BuildArgs, " -target" ) != BuildArgs.end () &&
2082- " missing target option" );
2083- for (unsigned idx = 0 , end = BuildArgs.size (); idx < end; ++idx) {
2084- if (BuildArgs[idx] == " -target" && ++idx < end)
2085- BuildArgs[idx] = parsedTargetTriple.str ();
2086- }
2087-
20882061 // restore `StrictImplicitModuleContext`
20892062 subInvocation.getFrontendOptions ().StrictImplicitModuleContext =
20902063 StrictImplicitModuleContext;
0 commit comments