1
1
//! The AOT driver uses [`cranelift_object`] to write object files suitable for linking into a
2
2
//! standalone executable.
3
3
4
+ use std:: env;
4
5
use std:: fs:: { self , File } ;
5
6
use std:: io:: BufWriter ;
6
7
use std:: path:: { Path , PathBuf } ;
@@ -25,13 +26,16 @@ use rustc_middle::mir::mono::{CodegenUnit, MonoItem};
25
26
use rustc_session:: Session ;
26
27
use rustc_session:: config:: { DebugInfo , OutFileName , OutputFilenames , OutputType } ;
27
28
28
- use crate :: BackendConfig ;
29
29
use crate :: concurrency_limiter:: { ConcurrencyLimiter , ConcurrencyLimiterToken } ;
30
30
use crate :: debuginfo:: TypeDebugContext ;
31
31
use crate :: global_asm:: GlobalAsmConfig ;
32
32
use crate :: prelude:: * ;
33
33
use crate :: unwind_module:: UnwindModule ;
34
34
35
+ fn disable_incr_cache ( ) -> bool {
36
+ env:: var ( "CG_CLIF_DISABLE_INCR_CACHE" ) . as_deref ( ) == Ok ( "1" )
37
+ }
38
+
35
39
struct ModuleCodegenResult {
36
40
module_regular : CompiledModule ,
37
41
module_global_asm : Option < CompiledModule > ,
@@ -63,10 +67,10 @@ impl OngoingCodegen {
63
67
self ,
64
68
sess : & Session ,
65
69
outputs : & OutputFilenames ,
66
- backend_config : & BackendConfig ,
67
70
) -> ( CodegenResults , FxIndexMap < WorkProductId , WorkProduct > ) {
68
71
let mut work_products = FxIndexMap :: default ( ) ;
69
72
let mut modules = vec ! [ ] ;
73
+ let disable_incr_cache = disable_incr_cache ( ) ;
70
74
71
75
for module_codegen in self . modules {
72
76
let module_codegen_result = match module_codegen {
@@ -87,7 +91,7 @@ impl OngoingCodegen {
87
91
if let Some ( ( work_product_id, work_product) ) = existing_work_product {
88
92
work_products. insert ( work_product_id, work_product) ;
89
93
} else {
90
- let work_product = if backend_config . disable_incr_cache {
94
+ let work_product = if disable_incr_cache {
91
95
None
92
96
} else if let Some ( module_global_asm) = & module_global_asm {
93
97
rustc_incremental:: copy_cgu_workproduct_to_incr_comp_cache_dir (
@@ -580,7 +584,6 @@ fn module_codegen(
580
584
581
585
pub ( crate ) fn run_aot (
582
586
tcx : TyCtxt < ' _ > ,
583
- backend_config : BackendConfig ,
584
587
metadata : EncodedMetadata ,
585
588
need_metadata_module : bool ,
586
589
) -> Box < OngoingCodegen > {
@@ -626,9 +629,10 @@ pub(crate) fn run_aot(
626
629
627
630
let global_asm_config = Arc :: new ( crate :: global_asm:: GlobalAsmConfig :: new ( tcx) ) ;
628
631
632
+ let disable_incr_cache = disable_incr_cache ( ) ;
629
633
let ( todo_cgus, done_cgus) =
630
634
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 ,
632
636
CguReuse :: No => true ,
633
637
CguReuse :: PreLto | CguReuse :: PostLto => false ,
634
638
} ) ;
0 commit comments