Skip to content

Commit e663819

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 e663819

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed

config.example.toml

+5
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

+8-4
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ 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",
49+
)
50+
o(
51+
"sccache",
52+
None,
53+
"invoke gcc/clang/rustc via sccache to reuse object files between builds",
4954
)
50-
o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds")
5155
o("local-rust", None, "use an installed rustc rather than downloading a snapshot")
5256
v("local-rust-root", None, "set prefix for local rust binary")
5357
o(
@@ -510,7 +514,7 @@ def apply_args(known_args, option_checking, config):
510514
build_triple = build(known_args)
511515

512516
if option.name == "sccache":
513-
set("llvm.ccache", "sccache", config)
517+
set("build.ccache", "sccache", config)
514518
elif option.name == "local-rust":
515519
for path in os.environ["PATH"].split(os.pathsep):
516520
if os.path.exists(path + "/rustc"):

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

+12-8
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

+5
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)