From ee45f6d6a943b111dc155c43a05d71550cdcc868 Mon Sep 17 00:00:00 2001 From: Steven Wu Date: Tue, 10 Sep 2024 10:57:24 -0700 Subject: [PATCH] [Modules] Make SubInstance spawn correctly under DirectCC1Mode Make sure ClangExtraArgs are inherited in the subinstance for module lookup/building when direct cc1 mode is used. This is useful for lldb, which does a slight different variant of the explicit module build that do not have swift-driver cooridination and replies on the subInstance to load swiftmodule. When such configuration is used, if DirectCC1 compile option is inherited without any extra cc1 arguments, the clang importer inside the sub-instance is actually malformed, causing the swift instance failed to be created. rdar://135611011 fixup --- lib/Frontend/ModuleInterfaceLoader.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index a0168460a27e4..b76334baf7164 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1953,9 +1953,13 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl( genericSubInvocation.getFrontendOptions() .DependencyScanningSubInvocation = true; } else if (LoaderOpts.strictImplicitModuleContext || - // Explicit module Interface verification jobs still spawn a sub-instance - // and we must ensure this sub-instance gets all of the Xcc flags. - LoaderOpts.disableImplicitSwiftModule) { + // Explicit module Interface verification jobs still spawn a + // sub-instance and we must ensure this sub-instance gets all of + // the Xcc flags. + LoaderOpts.disableImplicitSwiftModule || + // If using direct cc1 argument mode for lldb or typecheck + // interface, inherit all clang arguments. + clangImporterOpts.DirectClangCC1ModuleBuild) { // If the compiler has been asked to be strict with ensuring downstream // dependencies get the parent invocation's context, inherit the extra Clang // arguments also. Inherit any clang-specific state of the compilation