@@ -1431,12 +1431,10 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
1431
1431
SearchPathOpts.CandidateCompiledModules );
1432
1432
}
1433
1433
1434
- static bool readSwiftInterfaceVersionAndArgs (SourceManager &SM,
1435
- DiagnosticEngine &Diags,
1436
- llvm::StringSaver &ArgSaver,
1437
- SwiftInterfaceInfo &interfaceInfo,
1438
- StringRef interfacePath,
1439
- SourceLoc diagnosticLoc) {
1434
+ static bool readSwiftInterfaceVersionAndArgs (
1435
+ SourceManager &SM, DiagnosticEngine &Diags, llvm::StringSaver &ArgSaver,
1436
+ SwiftInterfaceInfo &interfaceInfo, StringRef interfacePath,
1437
+ SourceLoc diagnosticLoc, llvm::Triple preferredTarget) {
1440
1438
llvm::vfs::FileSystem &fs = *SM.getFileSystem ();
1441
1439
auto FileOrError = swift::vfs::getFileOrSTDIN (fs, interfacePath);
1442
1440
if (!FileOrError) {
@@ -1459,7 +1457,8 @@ static bool readSwiftInterfaceVersionAndArgs(SourceManager &SM,
1459
1457
}
1460
1458
1461
1459
if (extractCompilerFlagsFromInterface (interfacePath, SB, ArgSaver,
1462
- interfaceInfo.Arguments )) {
1460
+ interfaceInfo.Arguments ,
1461
+ preferredTarget)) {
1463
1462
InterfaceSubContextDelegateImpl::diagnose (
1464
1463
interfacePath, diagnosticLoc, SM, &Diags,
1465
1464
diag::error_extracting_version_from_module_interface);
@@ -1541,9 +1540,10 @@ bool ModuleInterfaceLoader::buildExplicitSwiftModuleFromSwiftInterface(
1541
1540
llvm::BumpPtrAllocator alloc;
1542
1541
llvm::StringSaver ArgSaver (alloc);
1543
1542
SwiftInterfaceInfo InterfaceInfo;
1544
- readSwiftInterfaceVersionAndArgs (Instance.getSourceMgr (), Instance.getDiags (),
1545
- ArgSaver, InterfaceInfo, interfacePath,
1546
- SourceLoc ());
1543
+ readSwiftInterfaceVersionAndArgs (
1544
+ Instance.getSourceMgr (), Instance.getDiags (), ArgSaver, InterfaceInfo,
1545
+ interfacePath, SourceLoc (),
1546
+ Instance.getInvocation ().getLangOptions ().Target );
1547
1547
1548
1548
auto Builder = ExplicitModuleInterfaceBuilder (
1549
1549
Instance, &Instance.getDiags (), Instance.getSourceMgr (),
@@ -1702,7 +1702,8 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
1702
1702
CompilerInvocation &subInvocation, SwiftInterfaceInfo &interfaceInfo,
1703
1703
StringRef interfacePath, SourceLoc diagnosticLoc) {
1704
1704
if (readSwiftInterfaceVersionAndArgs (SM, *Diags, ArgSaver, interfaceInfo,
1705
- interfacePath, diagnosticLoc))
1705
+ interfacePath, diagnosticLoc,
1706
+ subInvocation.getLangOptions ().Target ))
1706
1707
return true ;
1707
1708
1708
1709
SmallString<32 > ExpectedModuleName = subInvocation.getModuleName ();
@@ -1779,9 +1780,6 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1779
1780
GenericArgs.push_back (" -application-extension" );
1780
1781
}
1781
1782
1782
- // Save the parent invocation's Target Triple
1783
- ParentInvocationTarget = langOpts.Target ;
1784
-
1785
1783
// Pass down -explicit-swift-module-map-file
1786
1784
StringRef explicitSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
1787
1785
genericSubInvocation.getSearchPathOptions ().ExplicitSwiftModuleMap =
@@ -2054,31 +2052,6 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
2054
2052
return std::make_error_code (std::errc::not_supported);
2055
2053
}
2056
2054
2057
- // If the target triple parsed from the Swift interface file differs
2058
- // only in subarchitecture from the original target triple, then
2059
- // we have loaded a Swift interface from a different-but-compatible
2060
- // architecture slice. Use the original subarchitecture.
2061
- llvm::Triple parsedTargetTriple (subInvocation.getTargetTriple ());
2062
- if (parsedTargetTriple.getSubArch () != originalTargetTriple.getSubArch () &&
2063
- parsedTargetTriple.getArch () == originalTargetTriple.getArch () &&
2064
- parsedTargetTriple.getVendor () == originalTargetTriple.getVendor () &&
2065
- parsedTargetTriple.getOS () == originalTargetTriple.getOS () &&
2066
- parsedTargetTriple.getEnvironment ()
2067
- == originalTargetTriple.getEnvironment ()) {
2068
- parsedTargetTriple.setArchName (originalTargetTriple.getArchName ());
2069
- subInvocation.setTargetTriple (parsedTargetTriple.str ());
2070
- }
2071
-
2072
- // Find and overload all "-target" to be parsedTargetTriple. This make sure
2073
- // the build command for the interface is the same no matter what the parent
2074
- // triple is so there is no need to spawn identical jobs.
2075
- assert (llvm::find (BuildArgs, " -target" ) != BuildArgs.end () &&
2076
- " missing target option" );
2077
- for (unsigned idx = 0 , end = BuildArgs.size (); idx < end; ++idx) {
2078
- if (BuildArgs[idx] == " -target" && ++idx < end)
2079
- BuildArgs[idx] = parsedTargetTriple.str ();
2080
- }
2081
-
2082
2055
// restore `StrictImplicitModuleContext`
2083
2056
subInvocation.getFrontendOptions ().StrictImplicitModuleContext =
2084
2057
StrictImplicitModuleContext;
0 commit comments