Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/swift/Option/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,10 @@ def cache_compile_job: Flag<["-"], "cache-compile-job">,
Flags<[FrontendOption, NewDriverOnlyOption]>,
HelpText<"Enable compiler caching">;

def no_cache_compile_job: Flag<["-"], "no-cache-compile-job">,
Flags<[FrontendOption, NoDriverOption, HelpHidden]>,
HelpText<"Disable compiler caching">;

def cache_remarks: Flag<["-"], "Rcache-compile-job">,
Flags<[FrontendOption, NewDriverOnlyOption, CacheInvariant]>,
HelpText<"Show remarks for compiler caching">;
Expand Down
20 changes: 12 additions & 8 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,8 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args,
DiagnosticEngine &Diags,
const FrontendOptions &FrontendOpts) {
using namespace options;
Opts.EnableCaching |= Args.hasArg(OPT_cache_compile_job);
Opts.EnableCaching |= Args.hasFlag(
OPT_cache_compile_job, OPT_no_cache_compile_job, /*Default=*/false);
Opts.EnableCachingRemarks |= Args.hasArg(OPT_cache_remarks);
Opts.CacheSkipReplay |= Args.hasArg(OPT_cache_disable_replay);
if (const Arg *A = Args.getLastArg(OPT_cas_path))
Expand Down Expand Up @@ -2637,9 +2638,11 @@ static bool ParseDiagnosticArgs(DiagnosticOptions &Opts, ArgList &Args,
// If no style options are specified, default to Swift style, unless it is
// under swift caching, which llvm style is preferred because LLVM style
// replays a lot faster.
Opts.PrintedFormattingStyle = Args.hasArg(OPT_cache_compile_job)
? DiagnosticOptions::FormattingStyle::LLVM
: DiagnosticOptions::FormattingStyle::Swift;
Opts.PrintedFormattingStyle =
Args.hasFlag(OPT_cache_compile_job, OPT_no_cache_compile_job,
/*Default=*/false)
? DiagnosticOptions::FormattingStyle::LLVM
: DiagnosticOptions::FormattingStyle::Swift;
if (const Arg *arg = Args.getLastArg(OPT_diagnostic_style)) {
StringRef contents = arg->getValue();
if (contents == "llvm") {
Expand Down Expand Up @@ -3389,6 +3392,7 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
const FrontendOptions &FrontendOpts,
const SILOptions &SILOpts,
const LangOptions &LangOpts,
const CASOptions &CASOpts,
StringRef SDKPath,
StringRef ResourceDir,
const llvm::Triple &Triple) {
Expand Down Expand Up @@ -3628,8 +3632,8 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,

Opts.PrintInlineTree |= Args.hasArg(OPT_print_llvm_inline_tree);
// Always producing all outputs when caching is enabled.
Opts.AlwaysCompile |= Args.hasArg(OPT_always_compile_output_files) ||
Args.hasArg(OPT_cache_compile_job);
Opts.AlwaysCompile |=
Args.hasArg(OPT_always_compile_output_files) || CASOpts.EnableCaching;

Opts.EnableDynamicReplacementChaining |=
Args.hasArg(OPT_enable_dynamic_replacement_chaining);
Expand Down Expand Up @@ -4204,8 +4208,8 @@ bool CompilerInvocation::parseArgs(
}

if (ParseIRGenArgs(IRGenOpts, ParsedArgs, Diags, FrontendOpts, SILOpts,
LangOpts, getSDKPath(), SearchPathOpts.RuntimeResourcePath,
LangOpts.Target)) {
LangOpts, CASOpts, getSDKPath(),
SearchPathOpts.RuntimeResourcePath, LangOpts.Target)) {
return true;
}

Expand Down
1 change: 1 addition & 0 deletions test/CAS/cas_output_backend.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// RUN: mkdir -p %t/cas

// 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
// 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
// NO-CASFS: caching is enabled without CAS file-system options

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