1717//! also check out the `src/bootstrap/README.md` file for more information.
1818#![ cfg_attr( test, allow( unused) ) ]
1919
20- use std:: cell:: { Cell , RefCell } ;
20+ use std:: cell:: Cell ;
2121use std:: collections:: { BTreeSet , HashMap , HashSet } ;
2222use std:: fmt:: Display ;
2323use std:: path:: { Path , PathBuf } ;
@@ -190,10 +190,10 @@ pub struct Build {
190190
191191 // Runtime state filled in later on
192192 // C/C++ compilers and archiver for all targets
193- cc : RefCell < HashMap < TargetSelection , cc:: Tool > > ,
194- cxx : RefCell < HashMap < TargetSelection , cc:: Tool > > ,
195- ar : RefCell < HashMap < TargetSelection , PathBuf > > ,
196- ranlib : RefCell < HashMap < TargetSelection , PathBuf > > ,
193+ cc : HashMap < TargetSelection , cc:: Tool > ,
194+ cxx : HashMap < TargetSelection , cc:: Tool > ,
195+ ar : HashMap < TargetSelection , PathBuf > ,
196+ ranlib : HashMap < TargetSelection , PathBuf > ,
197197 // Miscellaneous
198198 // allow bidirectional lookups: both name -> path and path -> name
199199 crates : HashMap < String , Crate > ,
@@ -464,10 +464,10 @@ impl Build {
464464 enzyme_info,
465465 in_tree_llvm_info,
466466 in_tree_gcc_info,
467- cc : RefCell :: new ( HashMap :: new ( ) ) ,
468- cxx : RefCell :: new ( HashMap :: new ( ) ) ,
469- ar : RefCell :: new ( HashMap :: new ( ) ) ,
470- ranlib : RefCell :: new ( HashMap :: new ( ) ) ,
467+ cc : HashMap :: new ( ) ,
468+ cxx : HashMap :: new ( ) ,
469+ ar : HashMap :: new ( ) ,
470+ ranlib : HashMap :: new ( ) ,
471471 crates : HashMap :: new ( ) ,
472472 crate_paths : HashMap :: new ( ) ,
473473 is_sudo,
@@ -493,7 +493,7 @@ impl Build {
493493 }
494494
495495 build. verbose ( || println ! ( "finding compilers" ) ) ;
496- utils:: cc_detect:: find ( & build) ;
496+ utils:: cc_detect:: fill_compilers ( & mut build) ;
497497 // When running `setup`, the profile is about to change, so any requirements we have now may
498498 // be different on the next invocation. Don't check for them until the next time x.py is
499499 // run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
@@ -1133,17 +1133,17 @@ impl Build {
11331133 if self . config . dry_run ( ) {
11341134 return PathBuf :: new ( ) ;
11351135 }
1136- self . cc . borrow ( ) [ & target] . path ( ) . into ( )
1136+ self . cc [ & target] . path ( ) . into ( )
11371137 }
11381138
11391139 /// Returns the internal `cc::Tool` for the C compiler.
11401140 fn cc_tool ( & self , target : TargetSelection ) -> Tool {
1141- self . cc . borrow ( ) [ & target] . clone ( )
1141+ self . cc [ & target] . clone ( )
11421142 }
11431143
11441144 /// Returns the internal `cc::Tool` for the C++ compiler.
11451145 fn cxx_tool ( & self , target : TargetSelection ) -> Tool {
1146- self . cxx . borrow ( ) [ & target] . clone ( )
1146+ self . cxx [ & target] . clone ( )
11471147 }
11481148
11491149 /// Returns C flags that `cc-rs` thinks should be enabled for the
@@ -1153,8 +1153,8 @@ impl Build {
11531153 return Vec :: new ( ) ;
11541154 }
11551155 let base = match c {
1156- CLang :: C => self . cc . borrow ( ) [ & target] . clone ( ) ,
1157- CLang :: Cxx => self . cxx . borrow ( ) [ & target] . clone ( ) ,
1156+ CLang :: C => self . cc [ & target] . clone ( ) ,
1157+ CLang :: Cxx => self . cxx [ & target] . clone ( ) ,
11581158 } ;
11591159
11601160 // Filter out -O and /O (the optimization flags) that we picked up
@@ -1207,23 +1207,23 @@ impl Build {
12071207 if self . config . dry_run ( ) {
12081208 return None ;
12091209 }
1210- self . ar . borrow ( ) . get ( & target) . cloned ( )
1210+ self . ar . get ( & target) . cloned ( )
12111211 }
12121212
12131213 /// Returns the path to the `ranlib` utility for the target specified.
12141214 fn ranlib ( & self , target : TargetSelection ) -> Option < PathBuf > {
12151215 if self . config . dry_run ( ) {
12161216 return None ;
12171217 }
1218- self . ranlib . borrow ( ) . get ( & target) . cloned ( )
1218+ self . ranlib . get ( & target) . cloned ( )
12191219 }
12201220
12211221 /// Returns the path to the C++ compiler for the target specified.
12221222 fn cxx ( & self , target : TargetSelection ) -> Result < PathBuf , String > {
12231223 if self . config . dry_run ( ) {
12241224 return Ok ( PathBuf :: new ( ) ) ;
12251225 }
1226- match self . cxx . borrow ( ) . get ( & target) {
1226+ match self . cxx . get ( & target) {
12271227 Some ( p) => Ok ( p. path ( ) . into ( ) ) ,
12281228 None => Err ( format ! ( "target `{target}` is not configured as a host, only as a target" ) ) ,
12291229 }
@@ -1240,7 +1240,7 @@ impl Build {
12401240 } else if target. contains ( "vxworks" ) {
12411241 // need to use CXX compiler as linker to resolve the exception functions
12421242 // that are only existed in CXX libraries
1243- Some ( self . cxx . borrow ( ) [ & target] . path ( ) . into ( ) )
1243+ Some ( self . cxx [ & target] . path ( ) . into ( ) )
12441244 } else if !self . config . is_host_target ( target)
12451245 && helpers:: use_host_linker ( target)
12461246 && !target. is_msvc ( )
0 commit comments