From 9eee1ec4f4f093e1d338ba1343fa87d83f69573b Mon Sep 17 00:00:00 2001 From: Artem Chikin Date: Mon, 30 Oct 2023 16:41:40 -0700 Subject: [PATCH] [Dependency Scanning] Restore propagation of `-Xcc` flags to scanner's Swift Textual interface-reading sub-invocation --- lib/Frontend/ModuleInterfaceLoader.cpp | 3 ++- test/ScanDependencies/ObjCStrict.swift | 35 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/ScanDependencies/ObjCStrict.swift diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index 7643c6962bf00..5041f12a550ed 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1747,7 +1747,8 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl( // If the compiler has been asked to be strict with ensuring downstream dependencies // get the parent invocation's context, or this is an Explicit build, inherit the // extra Clang arguments also. - if (LoaderOpts.strictImplicitModuleContext || LoaderOpts.disableImplicitSwiftModule) { + if (LoaderOpts.strictImplicitModuleContext || LoaderOpts.disableImplicitSwiftModule || + LoaderOpts.requestedAction == FrontendOptions::ActionType::ScanDependencies) { // Inherit any clang-specific state of the compilation (macros, clang flags, etc.) subClangImporterOpts.ExtraArgs = clangImporterOpts.ExtraArgs; for (auto arg : subClangImporterOpts.ExtraArgs) { diff --git a/test/ScanDependencies/ObjCStrict.swift b/test/ScanDependencies/ObjCStrict.swift new file mode 100644 index 0000000000000..5ba108d5fabed --- /dev/null +++ b/test/ScanDependencies/ObjCStrict.swift @@ -0,0 +1,35 @@ +// RUN: %empty-directory(%t) +// RUN: %empty-directory(%t/clang-module-cache) + +// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/Inputs/CHeaders -I %S/Inputs/Swift -Xcc -fobjc-disable-direct-methods-for-testing +// Check the contents of the JSON output +// RUN: %validate-json %t/deps.json | %FileCheck %s + +// REQUIRES: executable_test +// REQUIRES: objc_interop + +import C + +// CHECK: "mainModuleName": "deps" +/// --------Main module +// CHECK-LABEL: "modulePath": "deps.swiftmodule", +// CHECK-NEXT: sourceFiles +// CHECK-NEXT: ObjCStrict.swift +// CHECK-NEXT: ], +// CHECK-NEXT: "directDependencies": [ +// CHECK-DAG: "clang": "C" +// CHECK-DAG: "swift": "Swift" +// CHECK-DAG: "swift": "SwiftOnoneSupport" +// CHECK-DAG: "swift": "_Concurrency" +// CHECK: ], + +// CHECK: "swift": "A" +// CHECK: "swift": { +// CHECK-NEXT: "moduleInterfacePath": "{{.*}}{{/|\\}}Inputs{{/|\\}}Swift{{/|\\}}A.swiftinterface", +// CHECK: "commandLine": [ +// CHECK: "-fobjc-disable-direct-methods-for-testing" +// CHECK: "-o", +// CHECK-NEXT: "{{.*}}{{/|\\}}A-{{.*}}.swiftmodule", + + +