Skip to content

Commit 9f87de6

Browse files
Rollup merge of #136941 - Kobzol:ccache-build, r=onur-ozkan
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 (#136921, https://rust-lang.zulipchat.com/#narrow/channel/242791-t-infra/topic/Using.20sccache.20for.20Rust). r? ``@onur-ozkan``
2 parents 1b603f9 + bd4f80c commit 9f87de6

File tree

4 files changed

+34
-15
lines changed

4 files changed

+34
-15
lines changed

Diff for: config.example.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@
8787
# Whether to build LLVM with support for it's gpu offload runtime.
8888
#offload = false
8989

90-
# Indicates whether ccache is used when building LLVM. Set to `true` to use the first `ccache` in
91-
# PATH, or set an absolute path to use a specific version.
92-
#ccache = false
93-
9490
# When true, link libstdc++ statically into the rustc_llvm.
9591
# This is useful if you don't want to use the dynamic version of that
9692
# library provided by LLVM.
@@ -424,6 +420,11 @@
424420
# What custom diff tool to use for displaying compiletest tests.
425421
#compiletest-diff-tool = <none>
426422

423+
# Indicates whether ccache is used when building certain artifacts (e.g. LLVM).
424+
# Set to `true` to use the first `ccache` in PATH, or set an absolute path to use
425+
# a specific version.
426+
#ccache = false
427+
427428
# =============================================================================
428429
# General install configuration options
429430
# =============================================================================

Diff for: 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"):

Diff for: src/bootstrap/src/core/config/config.rs

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

@@ -961,6 +962,7 @@ define_config! {
961962
tests: Option<bool> = "tests",
962963
enzyme: Option<bool> = "enzyme",
963964
plugins: Option<bool> = "plugins",
965+
// FIXME: Remove this field at Q2 2025, it has been replaced by build.ccache
964966
ccache: Option<StringOrBool> = "ccache",
965967
static_libstdcpp: Option<bool> = "static-libstdcpp",
966968
libzstd: Option<bool> = "libzstd",
@@ -1622,6 +1624,7 @@ impl Config {
16221624
optimized_compiler_builtins,
16231625
jobs,
16241626
compiletest_diff_tool,
1627+
mut ccache,
16251628
} = toml.build.unwrap_or_default();
16261629

16271630
config.jobs = Some(threads_from_config(flags.jobs.unwrap_or(jobs.unwrap_or(0))));
@@ -2006,7 +2009,7 @@ impl Config {
20062009
tests,
20072010
enzyme,
20082011
plugins,
2009-
ccache,
2012+
ccache: llvm_ccache,
20102013
static_libstdcpp,
20112014
libzstd,
20122015
ninja,
@@ -2029,13 +2032,11 @@ impl Config {
20292032
download_ci_llvm,
20302033
build_config,
20312034
} = 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 => {}
2035+
if llvm_ccache.is_some() {
2036+
eprintln!("Warning: llvm.ccache is deprecated. Use build.ccache instead.");
20382037
}
2038+
2039+
ccache = ccache.or(llvm_ccache);
20392040
set(&mut config.ninja_in_file, ninja);
20402041
llvm_tests = tests;
20412042
llvm_enzyme = enzyme;
@@ -2189,6 +2190,14 @@ impl Config {
21892190
}
21902191
}
21912192

2193+
match ccache {
2194+
Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()),
2195+
Some(StringOrBool::Bool(true)) => {
2196+
config.ccache = Some("ccache".to_string());
2197+
}
2198+
Some(StringOrBool::Bool(false)) | None => {}
2199+
}
2200+
21922201
if config.llvm_from_ci {
21932202
let triple = &config.build.triple;
21942203
let ci_llvm_bin = config.ci_llvm_root().join("bin");

Diff for: 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)