Skip to content

Commit c296402

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 c296402

File tree

4 files changed

+31
-20
lines changed

4 files changed

+31
-20
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

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

+17-16
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))));
@@ -1928,14 +1930,11 @@ impl Config {
19281930
config.rustc_default_linker = default_linker;
19291931
config.musl_root = musl_root.map(PathBuf::from);
19301932
config.save_toolstates = save_toolstates.map(PathBuf::from);
1931-
set(
1932-
&mut config.deny_warnings,
1933-
match flags.warnings {
1934-
Warnings::Deny => Some(true),
1935-
Warnings::Warn => Some(false),
1936-
Warnings::Default => deny_warnings,
1937-
},
1938-
);
1933+
set(&mut config.deny_warnings, match flags.warnings {
1934+
Warnings::Deny => Some(true),
1935+
Warnings::Warn => Some(false),
1936+
Warnings::Default => deny_warnings,
1937+
});
19391938
set(&mut config.backtrace_on_ice, backtrace_on_ice);
19401939
set(&mut config.rust_verify_llvm_ir, verify_llvm_ir);
19411940
config.rust_thin_lto_import_instr_limit = thin_lto_import_instr_limit;
@@ -2006,7 +2005,7 @@ impl Config {
20062005
tests,
20072006
enzyme,
20082007
plugins,
2009-
ccache,
2008+
ccache: llvm_ccache,
20102009
static_libstdcpp,
20112010
libzstd,
20122011
ninja,
@@ -2029,13 +2028,7 @@ impl Config {
20292028
download_ci_llvm,
20302029
build_config,
20312030
} = 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-
}
2031+
ccache = ccache.or(llvm_ccache);
20392032
set(&mut config.ninja_in_file, ninja);
20402033
llvm_tests = tests;
20412034
llvm_enzyme = enzyme;
@@ -2189,6 +2182,14 @@ impl Config {
21892182
}
21902183
}
21912184

2185+
match ccache {
2186+
Some(StringOrBool::String(ref s)) => config.ccache = Some(s.to_string()),
2187+
Some(StringOrBool::Bool(true)) => {
2188+
config.ccache = Some("ccache".to_string());
2189+
}
2190+
Some(StringOrBool::Bool(false)) | None => {}
2191+
}
2192+
21922193
if config.llvm_from_ci {
21932194
let triple = &config.build.triple;
21942195
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: 1234,
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)