@@ -1433,12 +1433,10 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
1433
1433
SearchPathOpts.CandidateCompiledModules );
1434
1434
}
1435
1435
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) {
1442
1440
llvm::vfs::FileSystem &fs = *SM.getFileSystem ();
1443
1441
auto FileOrError = swift::vfs::getFileOrSTDIN (fs, interfacePath);
1444
1442
if (!FileOrError) {
@@ -1461,7 +1459,8 @@ static bool readSwiftInterfaceVersionAndArgs(SourceManager &SM,
1461
1459
}
1462
1460
1463
1461
if (extractCompilerFlagsFromInterface (interfacePath, SB, ArgSaver,
1464
- interfaceInfo.Arguments )) {
1462
+ interfaceInfo.Arguments ,
1463
+ preferredTarget)) {
1465
1464
InterfaceSubContextDelegateImpl::diagnose (
1466
1465
interfacePath, diagnosticLoc, SM, &Diags,
1467
1466
diag::error_extracting_version_from_module_interface);
@@ -1543,9 +1542,10 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
1543
1542
llvm::BumpPtrAllocator alloc;
1544
1543
llvm::StringSaver ArgSaver (alloc);
1545
1544
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 );
1549
1549
1550
1550
auto Builder = ExplicitModuleInterfaceBuilder (
1551
1551
Instance, &Instance.getDiags (), Instance.getSourceMgr (),
@@ -1707,7 +1707,8 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
1707
1707
CompilerInvocation &subInvocation, SwiftInterfaceInfo &interfaceInfo,
1708
1708
StringRef interfacePath, SourceLoc diagnosticLoc) {
1709
1709
if (readSwiftInterfaceVersionAndArgs (SM, *Diags, ArgSaver, interfaceInfo,
1710
- interfacePath, diagnosticLoc))
1710
+ interfacePath, diagnosticLoc,
1711
+ subInvocation.getLangOptions ().Target ))
1711
1712
return true ;
1712
1713
1713
1714
// Prior to Swift 5.9, swiftinterfaces were always built (accidentally) with
@@ -1795,9 +1796,6 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1795
1796
GenericArgs.push_back (" -application-extension" );
1796
1797
}
1797
1798
1798
- // Save the parent invocation's Target Triple
1799
- ParentInvocationTarget = langOpts.Target ;
1800
-
1801
1799
// Pass down -explicit-swift-module-map-file
1802
1800
StringRef explicitSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
1803
1801
genericSubInvocation.getSearchPathOptions ().ExplicitSwiftModuleMap =
@@ -2060,31 +2058,6 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
2060
2058
BuildArgs.insert (BuildArgs.end (), interfaceInfo.Arguments .begin (),
2061
2059
interfaceInfo.Arguments .end ());
2062
2060
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
-
2088
2061
// restore `StrictImplicitModuleContext`
2089
2062
subInvocation.getFrontendOptions ().StrictImplicitModuleContext =
2090
2063
StrictImplicitModuleContext;
0 commit comments