@@ -1018,6 +1018,7 @@ class ModuleInterfaceLoaderImpl {
10181018 builder.addExtraDependency (modulePath);
10191019 failed = builder.buildSwiftModule (cachedOutputPath,
10201020 /* shouldSerializeDeps*/ true ,
1021+ Opts.ignoreInterfaceProvidedOptions ,
10211022 &moduleBuffer, remarkRebuild);
10221023 }
10231024 if (!failed) {
@@ -1051,7 +1052,10 @@ class ModuleInterfaceLoaderImpl {
10511052 // calculated using the canonical interface file path to make sure we
10521053 // can find it from the canonical interface file.
10531054 auto failedAgain = fallbackBuilder.buildSwiftModule (cachedOutputPath,
1054- /* shouldSerializeDeps*/ true , &moduleBuffer, remarkRebuild);
1055+ /* shouldSerializeDeps*/ true ,
1056+ Opts.ignoreInterfaceProvidedOptions ,
1057+ &moduleBuffer,
1058+ remarkRebuild);
10551059 if (failedAgain)
10561060 return std::make_error_code (std::errc::invalid_argument);
10571061 assert (moduleBuffer);
@@ -1233,6 +1237,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
12331237 // FIXME: We really only want to serialize 'important' dependencies here, if
12341238 // we want to ship the built swiftmodules to another machine.
12351239 auto failed = builder.buildSwiftModule (OutPath, /* shouldSerializeDeps*/ true ,
1240+ LoaderOpts.ignoreInterfaceProvidedOptions ,
12361241 /* ModuleBuffer*/ nullptr , nullptr ,
12371242 SearchPathOpts.CandidateCompiledModules );
12381243 if (!failed)
@@ -1253,6 +1258,7 @@ bool ModuleInterfaceLoader::buildSwiftModuleFromSwiftInterface(
12531258 // FIXME: We really only want to serialize 'important' dependencies here, if
12541259 // we want to ship the built swiftmodules to another machine.
12551260 return backupBuilder.buildSwiftModule (OutPath, /* shouldSerializeDeps*/ true ,
1261+ LoaderOpts.ignoreInterfaceProvidedOptions ,
12561262 /* ModuleBuffer*/ nullptr , nullptr ,
12571263 SearchPathOpts.CandidateCompiledModules );
12581264}
@@ -1359,7 +1365,8 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
13591365 SmallVectorImpl<const char *> &SubArgs,
13601366 std::string &CompilerVersion,
13611367 StringRef interfacePath,
1362- SourceLoc diagnosticLoc) {
1368+ SourceLoc diagnosticLoc,
1369+ bool ignoreInterfaceProvidedOptions) {
13631370 llvm::vfs::FileSystem &fs = *SM.getFileSystem ();
13641371 auto FileOrError = swift::vfs::getFileOrSTDIN (fs, interfacePath);
13651372 if (!FileOrError) {
@@ -1379,10 +1386,13 @@ bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs(
13791386 diag::error_extracting_version_from_module_interface);
13801387 return true ;
13811388 }
1382- if (extractCompilerFlagsFromInterface (interfacePath, SB, ArgSaver, SubArgs)) {
1383- diagnose (interfacePath, diagnosticLoc,
1384- diag::error_extracting_version_from_module_interface);
1385- return true ;
1389+
1390+ if (!ignoreInterfaceProvidedOptions) {
1391+ if (extractCompilerFlagsFromInterface (interfacePath, SB, ArgSaver, SubArgs)) {
1392+ diagnose (interfacePath, diagnosticLoc,
1393+ diag::error_extracting_version_from_module_interface);
1394+ return true ;
1395+ }
13861396 }
13871397 assert (VersMatches.size () == 2 );
13881398 // FIXME We should diagnose this at a location that makes sense:
@@ -1463,6 +1473,9 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
14631473 genericSubInvocation.getFrontendOptions ().DisableImplicitModules = true ;
14641474 GenericArgs.push_back (" -disable-implicit-swift-modules" );
14651475 }
1476+ // Save the parent invocation's Target Triple
1477+ ParentInvocationTarget = langOpts.Target ;
1478+
14661479 // Pass down -explicit-swift-module-map-file
14671480 // FIXME: we shouldn't need this. Remove it?
14681481 StringRef explicitSwiftModuleMap = searchPathOpts.ExplicitSwiftModuleMap ;
@@ -1600,9 +1613,11 @@ InterfaceSubContextDelegateImpl::runInSubContext(StringRef moduleName,
16001613 StringRef interfacePath,
16011614 StringRef outputPath,
16021615 SourceLoc diagLoc,
1616+ bool ignoreInterfaceProvidedOptions,
16031617 llvm::function_ref<std::error_code(ASTContext&, ModuleDecl*, ArrayRef<StringRef>,
16041618 ArrayRef<StringRef>, StringRef)> action) {
16051619 return runInSubCompilerInstance (moduleName, interfacePath, outputPath, diagLoc,
1620+ ignoreInterfaceProvidedOptions,
16061621 [&](SubCompilerInstanceInfo &info){
16071622 return action (info.Instance ->getASTContext (),
16081623 info.Instance ->getMainModule (),
@@ -1617,6 +1632,7 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
16171632 StringRef interfacePath,
16181633 StringRef outputPath,
16191634 SourceLoc diagLoc,
1635+ bool ignoreInterfaceProvidedOptions,
16201636 llvm::function_ref<std::error_code(SubCompilerInstanceInfo&)> action) {
16211637 // We are about to mess up the compiler invocation by using the compiler
16221638 // arguments in the textual interface file. So copy to use a new compiler
@@ -1674,9 +1690,11 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
16741690 SubArgs,
16751691 CompilerVersion,
16761692 interfacePath,
1677- diagLoc)) {
1693+ diagLoc,
1694+ ignoreInterfaceProvidedOptions)) {
16781695 return std::make_error_code (std::errc::not_supported);
16791696 }
1697+
16801698 // Insert arguments collected from the interface file.
16811699 BuildArgs.insert (BuildArgs.end (), SubArgs.begin (), SubArgs.end ());
16821700 if (subInvocation.parseArgs (SubArgs, *Diags)) {
@@ -1693,9 +1711,13 @@ InterfaceSubContextDelegateImpl::runInSubCompilerInstance(StringRef moduleName,
16931711 parsedTargetTriple.getVendor () == originalTargetTriple.getVendor () &&
16941712 parsedTargetTriple.getOS () == originalTargetTriple.getOS () &&
16951713 parsedTargetTriple.getEnvironment ()
1696- == originalTargetTriple.getEnvironment ()) {
1714+ == originalTargetTriple.getEnvironment ()) {
16971715 parsedTargetTriple.setArchName (originalTargetTriple.getArchName ());
16981716 subInvocation.setTargetTriple (parsedTargetTriple.str ());
1717+
1718+ // Overload the target in the BuildArgs as well
1719+ BuildArgs.push_back (" -target" );
1720+ BuildArgs.push_back (parsedTargetTriple.str ());
16991721 }
17001722
17011723 CompilerInstance subInstance;
0 commit comments