Skip to content

Commit 0b344f8

Browse files
Merge pull request #85250 from cachemeifyoucan/eng/PR-162547707
[CAS] Add `-no-cache-compile-job` frontend option
2 parents c978386 + eae4555 commit 0b344f8

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

include/swift/Option/Options.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,10 @@ def cache_compile_job: Flag<["-"], "cache-compile-job">,
22752275
Flags<[FrontendOption, NewDriverOnlyOption]>,
22762276
HelpText<"Enable compiler caching">;
22772277

2278+
def no_cache_compile_job: Flag<["-"], "no-cache-compile-job">,
2279+
Flags<[FrontendOption, NoDriverOption, HelpHidden]>,
2280+
HelpText<"Disable compiler caching">;
2281+
22782282
def cache_remarks: Flag<["-"], "Rcache-compile-job">,
22792283
Flags<[FrontendOption, NewDriverOnlyOption, CacheInvariant]>,
22802284
HelpText<"Show remarks for compiler caching">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,8 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args,
782782
DiagnosticEngine &Diags,
783783
const FrontendOptions &FrontendOpts) {
784784
using namespace options;
785-
Opts.EnableCaching |= Args.hasArg(OPT_cache_compile_job);
785+
Opts.EnableCaching |= Args.hasFlag(
786+
OPT_cache_compile_job, OPT_no_cache_compile_job, /*Default=*/false);
786787
Opts.EnableCachingRemarks |= Args.hasArg(OPT_cache_remarks);
787788
Opts.CacheSkipReplay |= Args.hasArg(OPT_cache_disable_replay);
788789
if (const Arg *A = Args.getLastArg(OPT_cas_path))
@@ -2637,9 +2638,11 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
26372638
// If no style options are specified, default to Swift style, unless it is
26382639
// under swift caching, which llvm style is preferred because LLVM style
26392640
// replays a lot faster.
2640-
Opts.PrintedFormattingStyle = Args.hasArg(OPT_cache_compile_job)
2641-
? DiagnosticOptions::FormattingStyle::LLVM
2642-
: DiagnosticOptions::FormattingStyle::Swift;
2641+
Opts.PrintedFormattingStyle =
2642+
Args.hasFlag(OPT_cache_compile_job, OPT_no_cache_compile_job,
2643+
/*Default=*/false)
2644+
? DiagnosticOptions::FormattingStyle::LLVM
2645+
: DiagnosticOptions::FormattingStyle::Swift;
26432646
if (const Arg *arg = Args.getLastArg(OPT_diagnostic_style)) {
26442647
StringRef contents = arg->getValue();
26452648
if (contents == "llvm") {
@@ -3389,6 +3392,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
33893392
const FrontendOptions &FrontendOpts,
33903393
const SILOptions &SILOpts,
33913394
const LangOptions &LangOpts,
3395+
const CASOptions &CASOpts,
33923396
StringRef SDKPath,
33933397
StringRef ResourceDir,
33943398
const llvm::Triple &Triple) {
@@ -3628,8 +3632,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
36283632

36293633
Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
36303634
// Always producing all outputs when caching is enabled.
3631-
Opts.AlwaysCompile |= Args.hasArg(OPT_always_compile_output_files) ||
3632-
Args.hasArg(OPT_cache_compile_job);
3635+
Opts.AlwaysCompile |=
3636+
Args.hasArg(OPT_always_compile_output_files) || CASOpts.EnableCaching;
36333637

36343638
Opts.EnableDynamicReplacementChaining |=
36353639
Args.hasArg(OPT_enable_dynamic_replacement_chaining);
@@ -4204,8 +4208,8 @@ bool CompilerInvocation::parseArgs(
42044208
}
42054209

42064210
if (ParseIRGenArgs(IRGenOpts, ParsedArgs, Diags, FrontendOpts, SILOpts,
4207-
LangOpts, getSDKPath(), SearchPathOpts.RuntimeResourcePath,
4208-
LangOpts.Target)) {
4211+
LangOpts, CASOpts, getSDKPath(),
4212+
SearchPathOpts.RuntimeResourcePath, LangOpts.Target)) {
42094213
return true;
42104214
}
42114215

test/CAS/cas_output_backend.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// RUN: mkdir -p %t/cas
33

44
// RUN: not %target-swift-frontend -c -cache-compile-job -cas-path %t/cas %s -o %t/test.o 2>&1 | %FileCheck %s --check-prefix=NO-CASFS
5+
// RUN: not %target-swift-frontend -c -no-cache-compile-job -cache-compile-job -cas-path %t/cas %s -o %t/test.o 2>&1 | %FileCheck %s --check-prefix=NO-CASFS
56
// NO-CASFS: caching is enabled without CAS file-system options
67

78
// RUN: %target-swift-frontend -scan-dependencies -module-name Test -O \

0 commit comments

Comments
 (0)