Skip to content

Commit 51d4cd7

Browse files
Merge pull request #69681 from cachemeifyoucan/eng/PR-swift-caching-configuration
Swift Caching related configuration/configuration file change: Use clang-include-tree by default for clang modules Add swift caching to feature JSON file.
2 parents 4e821f6 + 109566f commit 51d4cd7

10 files changed

+25
-20
lines changed

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,8 +1274,8 @@ def input_file_key : Separate<["-"], "input-file-key">,
12741274
def bridging_header_pch_key : Separate<["-"], "bridging-header-pch-key">,
12751275
HelpText<"Cache Key for bridging header pch">;
12761276

1277-
def clang_include_tree: Flag<["-"], "clang-include-tree">,
1278-
HelpText<"Use clang include tree">;
1277+
def no_clang_include_tree: Flag<["-"], "no-clang-include-tree">,
1278+
HelpText<"Do not use clang include tree, fallback to use CAS filesystem to build clang modules">;
12791279

12801280
def cas_fs: Separate<["-"], "cas-fs">,
12811281
HelpText<"Root CASID for CAS FileSystem">, MetaVarName<"<cas-id>">;

lib/ClangImporter/ClangModuleDependencyScanner.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,12 @@ ModuleDependencyVector ClangImporter::bridgeClangModuleDependencies(
259259
}
260260

261261
if (!RootID.empty()) {
262+
swiftArgs.push_back("-no-clang-include-tree");
262263
swiftArgs.push_back("-cas-fs");
263264
swiftArgs.push_back(RootID);
264265
}
265266

266267
if (!IncludeTree.empty()) {
267-
swiftArgs.push_back("-clang-include-tree");
268268
swiftArgs.push_back("-clang-include-tree-root");
269269
swiftArgs.push_back(IncludeTree);
270270
}
@@ -368,11 +368,11 @@ void ClangImporter::recordBridgingHeaderOptions(
368368
}
369369

370370
if (auto Tree = deps.IncludeTreeID) {
371-
swiftArgs.push_back("-clang-include-tree");
372371
swiftArgs.push_back("-clang-include-tree-root");
373372
swiftArgs.push_back(*Tree);
374373
}
375374
if (auto CASFS = deps.CASFileSystemRootID) {
375+
swiftArgs.push_back("-no-clang-include-tree");
376376
swiftArgs.push_back("-cas-fs");
377377
swiftArgs.push_back(*CASFS);
378378
}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,7 +1605,6 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
16051605

16061606
Opts.ExtraArgsOnly |= Args.hasArg(OPT_extra_clang_options_only);
16071607
Opts.DirectClangCC1ModuleBuild |= Args.hasArg(OPT_direct_clang_cc1_module_build);
1608-
Opts.UseClangIncludeTree |= Args.hasArg(OPT_clang_include_tree);
16091608

16101609
if (const Arg *A = Args.getLastArg(OPT_pch_output_dir)) {
16111610
Opts.PrecompiledHeaderOutputDir = A->getValue();
@@ -1632,8 +1631,12 @@ static bool ParseClangImporterArgs(ClangImporterOptions &Opts, ArgList &Args,
16321631

16331632
// Forward the FrontendOptions to clang importer option so it can be
16341633
// accessed when creating clang module compilation invocation.
1635-
if (FrontendOpts.EnableCaching)
1634+
if (FrontendOpts.EnableCaching) {
16361635
Opts.CASOpts = FrontendOpts.CASOpts;
1636+
// Only set UseClangIncludeTree when caching is enabled since it is not
1637+
// useful in non-caching context.
1638+
Opts.UseClangIncludeTree = !Args.hasArg(OPT_no_clang_include_tree);
1639+
}
16371640

16381641
return false;
16391642
}

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,10 +1655,9 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface(
16551655
}
16561656
}
16571657

1658-
if (clangImporterOpts.UseClangIncludeTree) {
1659-
genericSubInvocation.getClangImporterOptions().UseClangIncludeTree =
1660-
clangImporterOpts.UseClangIncludeTree;
1661-
GenericArgs.push_back("-clang-include-tree");
1658+
if (!clangImporterOpts.UseClangIncludeTree) {
1659+
genericSubInvocation.getClangImporterOptions().UseClangIncludeTree = false;
1660+
GenericArgs.push_back("-no-clang-include-tree");
16621661
}
16631662
}
16641663

lib/Option/features.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
},
3939
{
4040
"name": "ld-path-driver-option"
41+
},
42+
{
43+
"name": "cache-compile-job"
4144
}
4245
]
4346
}

test/CAS/module_deps.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: mkdir -p %t/clang-module-cache
55
// RUN: mkdir -p %t/cas
66

7-
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas
7+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas -no-clang-include-tree
88
// Check the contents of the JSON output
99
// RUN: %validate-json %t/deps.json &>/dev/null
1010
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
@@ -15,12 +15,12 @@
1515
// Check the make-style dependencies file
1616
// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d
1717

18-
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas
18+
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas -no-clang-include-tree
1919
// RUN: %validate-json %t/deps.json &>/dev/null
2020
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
2121

2222
// Ensure that scanning with `-clang-target` makes sure that Swift modules' respective PCM-dependency-build-argument sets do not contain target triples.
23-
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -cas-path %t/cas
23+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -cas-path %t/cas -no-clang-include-tree
2424
// Check the contents of the JSON output
2525
// RUN: %validate-json %t/deps_clang_target.json &>/dev/null
2626
// RUN: %FileCheck -check-prefix CHECK_CLANG_TARGET %s < %t/deps_clang_target.json

test/CAS/module_deps_clang_extras.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// RUN: %hmaptool write %t/hmap.json %t/empty.hmap
88

99
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache \
10-
// RUN: %t/Test.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas -clang-include-tree \
10+
// RUN: %t/Test.swift -o %t/deps.json -cache-compile-job -cas-path %t/cas \
1111
// RUN: -Xcc -fmodule-map-file=%t/module.modulemap -Xcc -ivfsoverlay -Xcc %t/empty.yaml \
1212
// RUN: -Xcc -I%t/empty.hmap
1313
// RUN: %validate-json %t/deps.json &>/dev/null

test/CAS/module_deps_include_tree.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// RUN: mkdir -p %t/clang-module-cache
55
// RUN: mkdir -p %t/cas
66

7-
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas -clang-include-tree
7+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas
88
// Check the contents of the JSON output
99
// RUN: %validate-json %t/deps.json &>/dev/null
1010
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
@@ -15,12 +15,12 @@
1515
// Check the make-style dependencies file
1616
// RUN: %FileCheck %s -check-prefix CHECK-MAKE-DEPS < %t/deps.d
1717

18-
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas -clang-include-tree
18+
// RUN: %target-swift-frontend -scan-dependencies -test-dependency-scan-cache-serialization -module-cache-path %t/clang-module-cache %s -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job -cas-path %t/cas
1919
// RUN: %validate-json %t/deps.json &>/dev/null
2020
// RUN: %FileCheck -check-prefix CHECK -check-prefix CHECK_NO_CLANG_TARGET %s < %t/deps.json
2121

2222
// Ensure that scanning with `-clang-target` makes sure that Swift modules' respective PCM-dependency-build-argument sets do not contain target triples.
23-
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -cas-path %t/cas -clang-include-tree
23+
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -cas-path %t/cas
2424
// Check the contents of the JSON output
2525
// RUN: %validate-json %t/deps_clang_target.json &>/dev/null
2626
// RUN: %FileCheck -check-prefix CHECK_CLANG_TARGET %s < %t/deps_clang_target.json

test/CAS/module_path_remap.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s -o %t/deps.json \
88
// RUN: -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift -emit-dependencies \
99
// RUN: -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h -swift-version 4 -cache-compile-job \
10-
// RUN: -cas-path %t/cas -clang-include-tree -scanner-prefix-map %swift_src_root=/^src -scanner-prefix-map %t=/^tmp
10+
// RUN: -cas-path %t/cas -scanner-prefix-map %swift_src_root=/^src -scanner-prefix-map %t=/^tmp
1111

1212
// RUN: %S/Inputs/SwiftDepsExtractor.py %t/deps.json deps casFSRootID > %t/deps.fs.casid
1313
// RUN: llvm-cas --cas %t/cas --ls-tree-recursive @%t/deps.fs.casid | %FileCheck %s -check-prefix DEPS-FS

test/CAS/plugin_cas.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s \
88
// RUN: -o %t/deps.json -I %S/../ScanDependencies/Inputs/CHeaders -I %S/../ScanDependencies/Inputs/Swift \
99
// RUN: -emit-dependencies -emit-dependencies-path %t/deps.d -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h \
10-
// RUN: -swift-version 4 -cache-compile-job -clang-include-tree \
10+
// RUN: -swift-version 4 -cache-compile-job \
1111
// RUN: -cas-path %t/cas \
1212
// RUN: -cas-plugin-path %llvm_libs_dir/libCASPluginTest%llvm_plugin_ext \
1313
// RUN: -cas-plugin-option first-prefix=myfirst- -cas-plugin-option second-prefix=mysecond- \
@@ -26,7 +26,7 @@
2626
// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t/clang-module-cache %s \
2727
// RUN: -o %t/deps_clang_target.json -I %S/../ScanDependencies/Inputs/CHeaders \
2828
// RUN: -I %S/../ScanDependencies/Inputs/Swift -import-objc-header %S/../ScanDependencies/Inputs/CHeaders/Bridging.h \
29-
// RUN: -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job -clang-include-tree \
29+
// RUN: -swift-version 4 -clang-target %target-cpu-apple-macosx10.14 -cache-compile-job \
3030
// RUN: -cas-path %t/cas \
3131
// RUN: -cas-plugin-path %llvm_libs_dir/libCASPluginTest%llvm_plugin_ext \
3232
// RUN: -cas-plugin-option first-prefix=myfirst- -cas-plugin-option second-prefix=mysecond- \

0 commit comments

Comments
 (0)