11//! The AOT driver uses [`cranelift_object`] to write object files suitable for linking into a
22//! standalone executable.
33
4+ use std:: env;
45use std:: fs:: { self , File } ;
56use std:: io:: BufWriter ;
67use std:: path:: { Path , PathBuf } ;
@@ -25,13 +26,16 @@ use rustc_middle::mir::mono::{CodegenUnit, MonoItem};
2526use rustc_session:: Session ;
2627use rustc_session:: config:: { DebugInfo , OutFileName , OutputFilenames , OutputType } ;
2728
28- use crate :: BackendConfig ;
2929use crate :: concurrency_limiter:: { ConcurrencyLimiter , ConcurrencyLimiterToken } ;
3030use crate :: debuginfo:: TypeDebugContext ;
3131use crate :: global_asm:: GlobalAsmConfig ;
3232use crate :: prelude:: * ;
3333use crate :: unwind_module:: UnwindModule ;
3434
35+ fn disable_incr_cache ( ) -> bool {
36+ env:: var ( "CG_CLIF_DISABLE_INCR_CACHE" ) . as_deref ( ) == Ok ( "1" )
37+ }
38+
3539struct ModuleCodegenResult {
3640 module_regular : CompiledModule ,
3741 module_global_asm : Option < CompiledModule > ,
@@ -63,10 +67,10 @@ impl OngoingCodegen {
6367 self ,
6468 sess : & Session ,
6569 outputs : & OutputFilenames ,
66- backend_config : & BackendConfig ,
6770 ) -> ( CodegenResults , FxIndexMap < WorkProductId , WorkProduct > ) {
6871 let mut work_products = FxIndexMap :: default ( ) ;
6972 let mut modules = vec ! [ ] ;
73+ let disable_incr_cache = disable_incr_cache ( ) ;
7074
7175 for module_codegen in self . modules {
7276 let module_codegen_result = match module_codegen {
@@ -87,7 +91,7 @@ impl OngoingCodegen {
8791 if let Some ( ( work_product_id, work_product) ) = existing_work_product {
8892 work_products. insert ( work_product_id, work_product) ;
8993 } else {
90- let work_product = if backend_config . disable_incr_cache {
94+ let work_product = if disable_incr_cache {
9195 None
9296 } else if let Some ( module_global_asm) = & module_global_asm {
9397 rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
@@ -580,7 +584,6 @@ fn module_codegen(
580584
581585pub ( crate ) fn run_aot (
582586 tcx : TyCtxt < ' _ > ,
583- backend_config : BackendConfig ,
584587 metadata : EncodedMetadata ,
585588 need_metadata_module : bool ,
586589) -> Box < OngoingCodegen > {
@@ -626,9 +629,10 @@ pub(crate) fn run_aot(
626629
627630 let global_asm_config = Arc :: new ( crate :: global_asm:: GlobalAsmConfig :: new ( tcx) ) ;
628631
632+ let disable_incr_cache = disable_incr_cache ( ) ;
629633 let ( todo_cgus, done_cgus) =
630634 cgus. into_iter ( ) . enumerate ( ) . partition :: < Vec < _ > , _ > ( |& ( i, _) | match cgu_reuse[ i] {
631- _ if backend_config . disable_incr_cache => true ,
635+ _ if disable_incr_cache => true ,
632636 CguReuse :: No => true ,
633637 CguReuse :: PreLto | CguReuse :: PostLto => false ,
634638 } ) ;
0 commit comments