@@ -1448,6 +1448,7 @@ void ModuleInterfaceLoader::collectVisibleTopLevelModuleNames(
14481448
14491449void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface (
14501450 const SearchPathOptions &SearchPathOpts, const LangOptions &LangOpts,
1451+ const ClangImporterOptions &clangImporterOpts,
14511452 bool suppressRemarks, RequireOSSAModules_t RequireOSSAModules) {
14521453 GenericArgs.push_back (" -frontend" );
14531454 // Start with a genericSubInvocation that copies various state from our
@@ -1544,6 +1545,16 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
15441545 genericSubInvocation.getLangOptions ().Features .insert (
15451546 Feature::LayoutPrespecialization);
15461547 }
1548+
1549+ // Validate Clang modules once per-build session flags must be consistent
1550+ // across all module sub-invocations
1551+ if (clangImporterOpts.ValidateModulesOnce ) {
1552+ genericSubInvocation.getClangImporterOptions ().ValidateModulesOnce = true ;
1553+ genericSubInvocation.getClangImporterOptions ().BuildSessionFilePath = clangImporterOpts.BuildSessionFilePath ;
1554+ GenericArgs.push_back (" -validate-clang-modules-once" );
1555+ GenericArgs.push_back (" -clang-build-session-file" );
1556+ GenericArgs.push_back (clangImporterOpts.BuildSessionFilePath );
1557+ }
15471558}
15481559
15491560bool InterfaceSubContextDelegateImpl::extractSwiftInterfaceVersionAndArgs (
@@ -1586,6 +1597,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
15861597 : SM(SM), Diags(Diags), ArgSaver(Allocator) {
15871598 genericSubInvocation.setMainExecutablePath (LoaderOpts.mainExecutablePath );
15881599 inheritOptionsForBuildingInterface (searchPathOpts, langOpts,
1600+ clangImporterOpts,
15891601 Diags->getSuppressRemarks (),
15901602 requireOSSAModules);
15911603 // Configure front-end input.
@@ -1621,6 +1633,7 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
16211633 genericSubInvocation.getLangOptions ().EnableAppExtensionRestrictions = true ;
16221634 GenericArgs.push_back (" -application-extension" );
16231635 }
1636+
16241637 // Save the parent invocation's Target Triple
16251638 ParentInvocationTarget = langOpts.Target ;
16261639
0 commit comments