Skip to content

Commit f37676f

Browse files
Rollup merge of rust-lang#157435 - bjorn3:disable_backend_incr_comp, r=lqd
Introduce -Zdisable-incr-comp-backend-caching This disables caching of compiled objects by the codegen backend during incremental compilation. This is useful for iterating on a codegen backend without having to run the entire rustc frontend from scratch every time when recompiling the standard library. Currently cg_clif has the CG_CLIF_DISABLE_INCR_CACHE env var that does this, but once cg_clif switches to the codegen coordinator of cg_ssa, it will no longer be possible for cg_clif to implement this. It has to be implemented in cg_ssa.
2 parents 148dc0e + f9f9adb commit f37676f

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ fn copy_all_cgu_workproducts_to_incr_comp_cache_dir(
463463
) -> FxIndexMap<WorkProductId, WorkProduct> {
464464
let mut work_products = FxIndexMap::default();
465465

466-
if sess.opts.incremental.is_none() {
466+
if sess.opts.incremental.is_none() || sess.opts.unstable_opts.disable_incr_comp_backend_caching
467+
{
467468
return work_products;
468469
}
469470

compiler/rustc_codegen_ssa/src/base.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,9 @@ pub(crate) fn provide(providers: &mut Providers) {
11321132
}
11331133

11341134
pub fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
1135-
if !tcx.dep_graph.is_fully_enabled() {
1135+
if !tcx.dep_graph.is_fully_enabled()
1136+
|| tcx.sess.opts.unstable_opts.disable_incr_comp_backend_caching
1137+
{
11361138
return CguReuse::No;
11371139
}
11381140

compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,6 +2298,8 @@ options! {
22982298
"Direct or use GOT indirect to reference external data symbols"),
22992299
disable_fast_paths: bool = (false, parse_bool, [TRACKED],
23002300
"disable various performance optimizations in trait solving"),
2301+
disable_incr_comp_backend_caching: bool = (false, parse_bool, [TRACKED],
2302+
"disable caching of compiled objects by the codegen backend during incremental compilation"),
23012303
dual_proc_macros: bool = (false, parse_bool, [TRACKED],
23022304
"load proc macros for both target and host, but only link to the target (default: no)"),
23032305
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],

0 commit comments

Comments
 (0)