mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[ScanDependency] Swift source module should not have build args for modules
When planning for a swift source module, it should not get build commands for its module dependencies. Those dependencies should be planned and added by swift-driver. This is another regression from #76700 that causes unnecessary increase of build command-line size. rdar://141843125
This commit is contained in:
@@ -309,11 +309,13 @@ private:
|
||||
llvm::Error handleSwiftInterfaceModuleDependency(
|
||||
ModuleDependencyID depModuleID,
|
||||
const SwiftInterfaceModuleDependenciesStorage &interfaceDepDetails) {
|
||||
auto &path = interfaceDepDetails.moduleCacheKey.empty()
|
||||
? interfaceDepDetails.moduleOutputPath
|
||||
: interfaceDepDetails.moduleCacheKey;
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName + "=" +
|
||||
path);
|
||||
if (!resolvingDepInfo.isSwiftSourceModule()) {
|
||||
auto &path = interfaceDepDetails.moduleCacheKey.empty()
|
||||
? interfaceDepDetails.moduleOutputPath
|
||||
: interfaceDepDetails.moduleCacheKey;
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName +
|
||||
"=" + path);
|
||||
}
|
||||
addMacroDependencies(depModuleID, interfaceDepDetails);
|
||||
return llvm::Error::success();
|
||||
}
|
||||
@@ -321,24 +323,27 @@ private:
|
||||
llvm::Error handleSwiftBinaryModuleDependency(
|
||||
ModuleDependencyID depModuleID,
|
||||
const SwiftBinaryModuleDependencyStorage &binaryDepDetails) {
|
||||
auto &path = binaryDepDetails.moduleCacheKey.empty()
|
||||
? binaryDepDetails.compiledModulePath
|
||||
: binaryDepDetails.moduleCacheKey;
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName + "=" +
|
||||
path);
|
||||
// If this binary module was built with a header, the header's module
|
||||
// dependencies must also specify a .modulemap to the compilation, in
|
||||
// order to resolve the header's own header include directives.
|
||||
for (const auto &bridgingHeaderDepID :
|
||||
binaryDepDetails.headerModuleDependencies) {
|
||||
auto optionalBridgingHeaderDepModuleInfo = cache.findKnownDependency(
|
||||
bridgingHeaderDepID);
|
||||
const auto bridgingHeaderDepModuleDetails =
|
||||
optionalBridgingHeaderDepModuleInfo.getAsClangModule();
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back("-fmodule-map-file=" +
|
||||
cache.getScanService().remapPath(
|
||||
bridgingHeaderDepModuleDetails->moduleMapFile));
|
||||
if (!resolvingDepInfo.isSwiftSourceModule()) {
|
||||
auto &path = binaryDepDetails.moduleCacheKey.empty()
|
||||
? binaryDepDetails.compiledModulePath
|
||||
: binaryDepDetails.moduleCacheKey;
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName +
|
||||
"=" + path);
|
||||
// If this binary module was built with a header, the header's module
|
||||
// dependencies must also specify a .modulemap to the compilation, in
|
||||
// order to resolve the header's own header include directives.
|
||||
for (const auto &bridgingHeaderDepID :
|
||||
binaryDepDetails.headerModuleDependencies) {
|
||||
auto optionalBridgingHeaderDepModuleInfo =
|
||||
cache.findKnownDependency(bridgingHeaderDepID);
|
||||
const auto bridgingHeaderDepModuleDetails =
|
||||
optionalBridgingHeaderDepModuleInfo.getAsClangModule();
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back(
|
||||
"-fmodule-map-file=" +
|
||||
cache.getScanService().remapPath(
|
||||
bridgingHeaderDepModuleDetails->moduleMapFile));
|
||||
}
|
||||
}
|
||||
addMacroDependencies(depModuleID, binaryDepDetails);
|
||||
return llvm::Error::success();
|
||||
@@ -347,26 +352,29 @@ private:
|
||||
llvm::Error handleSwiftPlaceholderModuleDependency(
|
||||
ModuleDependencyID depModuleID,
|
||||
const SwiftPlaceholderModuleDependencyStorage &placeholderDetails) {
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName + "=" +
|
||||
placeholderDetails.compiledModulePath);
|
||||
if (!resolvingDepInfo.isSwiftSourceModule())
|
||||
commandline.push_back("-swift-module-file=" + depModuleID.ModuleName +
|
||||
"=" + placeholderDetails.compiledModulePath);
|
||||
return llvm::Error::success();
|
||||
}
|
||||
|
||||
llvm::Error handleClangModuleDependency(
|
||||
ModuleDependencyID depModuleID,
|
||||
const ClangModuleDependencyStorage &clangDepDetails) {
|
||||
if (!resolvingDepInfo.isClangModule()) {
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back("-fmodule-file=" + depModuleID.ModuleName + "=" +
|
||||
clangDepDetails.mappedPCMPath);
|
||||
}
|
||||
if (!clangDepDetails.moduleCacheKey.empty()) {
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back("-fmodule-file-cache-key");
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back(clangDepDetails.mappedPCMPath);
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back(clangDepDetails.moduleCacheKey);
|
||||
if (!resolvingDepInfo.isSwiftSourceModule()) {
|
||||
if (!resolvingDepInfo.isClangModule()) {
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back("-fmodule-file=" + depModuleID.ModuleName + "=" +
|
||||
clangDepDetails.mappedPCMPath);
|
||||
}
|
||||
if (!clangDepDetails.moduleCacheKey.empty()) {
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back("-fmodule-file-cache-key");
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back(clangDepDetails.mappedPCMPath);
|
||||
commandline.push_back("-Xcc");
|
||||
commandline.push_back(clangDepDetails.moduleCacheKey);
|
||||
}
|
||||
}
|
||||
|
||||
// Collect CAS deppendencies from clang modules.
|
||||
@@ -1304,7 +1312,7 @@ bool swift::dependencies::scanDependencies(CompilerInstance &instance) {
|
||||
*service, instance.getMainModule()->getNameStr().str(),
|
||||
instance.getInvocation().getFrontendOptions().ExplicitModulesOutputPath,
|
||||
instance.getInvocation().getModuleScanningHash());
|
||||
|
||||
|
||||
if (opts.ReuseDependencyScannerCache)
|
||||
deserializeDependencyCache(instance, cache);
|
||||
|
||||
@@ -1391,7 +1399,7 @@ bool swift::dependencies::batchScanDependencies(
|
||||
return true;
|
||||
|
||||
auto batchScanResults = performBatchModuleScan(
|
||||
instance, /*DependencyScanDiagnosticCollector*/ nullptr,
|
||||
instance, /*DependencyScanDiagnosticCollector*/ nullptr,
|
||||
cache, /*versionedPCMInstanceCache*/ nullptr, saver,
|
||||
*batchInput);
|
||||
|
||||
@@ -1652,7 +1660,7 @@ swift::dependencies::performBatchModuleScan(
|
||||
}
|
||||
allDependencies = scanner.performDependencyScan(moduleID, cache);
|
||||
}
|
||||
|
||||
|
||||
batchScanResult.push_back(
|
||||
generateFullDependencyGraph(instance, diagnosticCollector, cache,
|
||||
allDependencies));
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json A > %t/A.cmd
|
||||
// RUN: %swift_frontend_plain @%t/A.cmd
|
||||
|
||||
// RUN: %{python} %S/Inputs/GenerateExplicitModuleMap.py %t/deps.json > %t/map.json
|
||||
// RUN: llvm-cas --cas %t/cas --make-blob --data %t/map.json > %t/map.casid
|
||||
// RUN: %{python} %S/Inputs/BuildCommandExtractor.py %t/deps.json Test > %t/Test.cmd
|
||||
// RUN: %target-swift-frontend -module-name Test -module-cache-path %t/clang-module-cache -O \
|
||||
// RUN: -parse-stdlib -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
|
||||
// RUN: %t/main.swift -o %t/Test.swiftmodule -swift-version 5 -cache-compile-job -cas-path %t/cas -I %t/include \
|
||||
// RUN: -explicit-swift-module-map-file @%t/map.casid \
|
||||
// RUN: -emit-symbol-graph -emit-symbol-graph-dir %t/symbol-graph1 \
|
||||
// RUN: -emit-module @%t/Test.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CACHE-MISS
|
||||
|
||||
@@ -22,6 +25,7 @@
|
||||
// RUN: %target-swift-frontend -module-name Test -module-cache-path %t/clang-module-cache -O \
|
||||
// RUN: -parse-stdlib -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
|
||||
// RUN: %t/main.swift -o %t/Test.swiftmodule -swift-version 5 -cache-compile-job -cas-path %t/cas -I %t/include \
|
||||
// RUN: -explicit-swift-module-map-file @%t/map.casid \
|
||||
// RUN: -emit-symbol-graph -emit-symbol-graph-dir %t/symbol-graph2 \
|
||||
// RUN: -emit-module @%t/Test.cmd -Rcache-compile-job 2>&1 | %FileCheck %s --check-prefix=CACHE-HIT
|
||||
|
||||
@@ -35,6 +39,7 @@
|
||||
// RUN: %target-swift-frontend -module-name Test -module-cache-path %t/clang-module-cache -O \
|
||||
// RUN: -parse-stdlib -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
|
||||
// RUN: %t/main.swift -o %t/Test.swiftmodule -swift-version 5 -cache-compile-job -cas-path %t/cas -I %t/include \
|
||||
// RUN: -explicit-swift-module-map-file @%t/map.casid \
|
||||
// RUN: -emit-symbol-graph -emit-symbol-graph-dir %t/symbol-graph3 \
|
||||
// RUN: -emit-module @%t/Test.cmd -Rcache-compile-job > %t/key.casid
|
||||
|
||||
@@ -42,6 +47,7 @@
|
||||
// RUN: %target-swift-frontend -module-name Test -module-cache-path %t/clang-module-cache -O \
|
||||
// RUN: -parse-stdlib -disable-implicit-string-processing-module-import -disable-implicit-concurrency-module-import \
|
||||
// RUN: %t/main.swift -o %t/Test.swiftmodule -swift-version 5 -cache-compile-job -cas-path %t/cas -I %t/include \
|
||||
// RUN: -explicit-swift-module-map-file @%t/map.casid \
|
||||
// RUN: -emit-symbol-graph -emit-symbol-graph-dir %t/symbol-graph3 \
|
||||
// RUN: -emit-module @%t/Test.cmd -Rcache-compile-job
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
// Check the contents of the JSON output
|
||||
// RUN: %validate-json %t/deps.json | %FileCheck -check-prefix CHECK_NO_CLANG_TARGET %s
|
||||
|
||||
// RUN: %{python} %S/../CAS/Inputs/BuildCommandExtractor.py %t/deps.json deps | %FileCheck --check-prefix CHECK-NO-MODULES %s --allow-empty
|
||||
// CHECK-NO-MODULES-NOT: -swift-module-file
|
||||
// CHECK-NO-MODULES-NOT: -fmodule-file
|
||||
|
||||
// Check the contents of the JSON output
|
||||
// RUN: %validate-json %t/deps.json | %FileCheck %s -check-prefix CHECK-NO-SEARCH-PATHS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user