Skip to content

Commit ff2a552

Browse files
committed
Move llvm.ccache to build.ccache
(S)ccache can be useful for more things that just LLVM. For example, we will soon want to use it also for GCC, and theoretically also for building stage0 Rust tools.
1 parent ced8e65 commit ff2a552

File tree

4 files changed

+26
-12
lines changed

4 files changed

+26
-12
lines changed

config.example.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,11 @@
424424
# What custom diff tool to use for displaying compiletest tests.
425425
#compiletest-diff-tool = <none>
426426

427+
# Indicates whether ccache is used when building certain artifacts (e.g. LLVM).
428+
# Set to `true` to use the first `ccache` in PATH, or set an absolute path to use
429+
# a specific version.
430+
#ccache = false
431+
427432
# =============================================================================
428433
# General install configuration options
429434
# =============================================================================

src/bootstrap/configure.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def v(*args):
4444
o("verbose-tests", "rust.verbose-tests", "enable verbose output when running tests")
4545
o(
4646
"ccache",
47-
"llvm.ccache",
48-
"invoke gcc/clang via ccache to reuse object files between builds",
47+
"build.ccache",
48+
"invoke gcc/clang/rustc via ccache to reuse object files between builds",
4949
)
50-
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds")
50+
o("sccache", None, "invoke gcc/clang/rustc via sccache to reuse object files between builds")
5151
o("local-rust", None, "use an installed rustc rather than downloading a snapshot")
5252
v("local-rust-root", None, "set prefix for local rust binary")
5353
o(
@@ -510,7 +510,7 @@ def apply_args(known_args, option_checking, config):
510510
build_triple = build(known_args)
511511

512512
if option.name == "sccache":
513-
set("llvm.ccache", "sccache", config)
513+
set("build.ccache", "sccache", config)
514514
elif option.name == "local-rust":
515515
for path in os.environ["PATH"].split(os.pathsep):
516516
if os.path.exists(path + "/rustc"):

src/bootstrap/src/core/config/config.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,7 @@ define_config! {
935935
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
936936
jobs: Option<u32> = "jobs",
937937
compiletest_diff_tool: Option<String> = "compiletest-diff-tool",
938+
ccache: Option<StringOrBool> = "ccache",
938939
}
939940
}
940941

@@ -1622,6 +1623,7 @@ impl Config {
16221623
optimized_compiler_builtins,
16231624
jobs,
16241625
compiletest_diff_tool,
1626+
mut ccache,
16251627
} = toml.build.unwrap_or_default();
16261628

16271629
config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));
@@ -2006,7 +2008,7 @@ impl Config {
20062008
tests,
20072009
enzyme,
20082010
plugins,
2009-
ccache,
2011+
ccache: llvm_ccache,
20102012
static_libstdcpp,
20112013
libzstd,
20122014
ninja,
@@ -2029,13 +2031,7 @@ impl Config {
20292031
download_ci_llvm,
20302032
build_config,
20312033
} = llvm;
2032-
match ccache {
2033-
Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()),
2034-
Some(StringOrBool::Bool(true)) => {
2035-
config.ccache = Some("ccache".to_string());
2036-
}
2037-
Some(StringOrBool::Bool(false)) | None => {}
2038-
}
2034+
ccache = ccache.or(llvm_ccache);
20392035
set(&mut config.ninja_in_file, ninja);
20402036
llvm_tests = tests;
20412037
llvm_enzyme = enzyme;
@@ -2189,6 +2185,14 @@ impl Config {
21892185
}
21902186
}
21912187

2188+
match ccache {
2189+
Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()),
2190+
Some(StringOrBool::Bool(true)) => {
2191+
config.ccache = Some("ccache".to_string());
2192+
}
2193+
Some(StringOrBool::Bool(false)) | None => {}
2194+
}
2195+
21922196
if config.llvm_from_ci {
21932197
let triple = &config.build.triple;
21942198
let ci_llvm_bin = config.ci_llvm_root().join("bin");

src/bootstrap/src/utils/change_tracker.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,4 +345,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
345345
severity: ChangeSeverity::Info,
346346
summary: "Rustdoc now respects the value of rust.lto.",
347347
},
348+
ChangeInfo {
349+
change_id: 136941,
350+
severity: ChangeSeverity::Info,
351+
summary: "The llvm.ccache option has moved to build.ccache. llvm.ccache is now deprecated.",
352+
},
348353
];

0 commit comments

Comments
 (0)