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 } ;
@@ -189,10 +189,12 @@ pub struct Build {
189189
190190 // Runtime state filled in later on
191191 // C/C++ compilers and archiver for all targets
192- cc : RefCell < HashMap < TargetSelection , cc:: Tool > > ,
193- cxx : RefCell < HashMap < TargetSelection , cc:: Tool > > ,
194- ar : RefCell < HashMap < TargetSelection , PathBuf > > ,
195- ranlib : RefCell < HashMap < TargetSelection , PathBuf > > ,
192+ cc : HashMap < TargetSelection , cc:: Tool > ,
193+ cxx : HashMap < TargetSelection , cc:: Tool > ,
194+ ar : HashMap < TargetSelection , PathBuf > ,
195+ ranlib : HashMap < TargetSelection , PathBuf > ,
196+ wasi_sdk_path : Option < PathBuf > ,
197+
196198 // Miscellaneous
197199 // allow bidirectional lookups: both name -> path and path -> name
198200 crates : HashMap < String , Crate > ,
@@ -466,10 +468,11 @@ impl Build {
466468 enzyme_info,
467469 in_tree_llvm_info,
468470 in_tree_gcc_info,
469- cc : RefCell :: new ( HashMap :: new ( ) ) ,
470- cxx : RefCell :: new ( HashMap :: new ( ) ) ,
471- ar : RefCell :: new ( HashMap :: new ( ) ) ,
472- ranlib : RefCell :: new ( HashMap :: new ( ) ) ,
471+ cc : HashMap :: new ( ) ,
472+ cxx : HashMap :: new ( ) ,
473+ ar : HashMap :: new ( ) ,
474+ ranlib : HashMap :: new ( ) ,
475+ wasi_sdk_path : env:: var_os ( "WASI_SDK_PATH" ) . map ( PathBuf :: from) ,
473476 crates : HashMap :: new ( ) ,
474477 crate_paths : HashMap :: new ( ) ,
475478 is_sudo,
@@ -498,7 +501,7 @@ impl Build {
498501 }
499502
500503 build. verbose ( || println ! ( "finding compilers" ) ) ;
501- utils:: cc_detect:: find ( & build) ;
504+ utils:: cc_detect:: fill_compilers ( & mut build) ;
502505 // When running `setup`, the profile is about to change, so any requirements we have now may
503506 // be different on the next invocation. Don't check for them until the next time x.py is
504507 // run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
@@ -593,14 +596,6 @@ impl Build {
593596 }
594597 }
595598
596- /// Updates all submodules, and exits with an error if submodule
597- /// management is disabled and the submodule does not exist.
598- pub fn require_and_update_all_submodules ( & self ) {
599- for submodule in build_helper:: util:: parse_gitmodules ( & self . src ) {
600- self . require_submodule ( submodule, None ) ;
601- }
602- }
603-
604599 /// If any submodule has been initialized already, sync it unconditionally.
605600 /// This avoids contributors checking in a submodule change by accident.
606601 fn update_existing_submodules ( & self ) {
@@ -1143,17 +1138,17 @@ impl Build {
11431138 if self . config . dry_run ( ) {
11441139 return PathBuf :: new ( ) ;
11451140 }
1146- self . cc . borrow ( ) [ & target] . path ( ) . into ( )
1141+ self . cc [ & target] . path ( ) . into ( )
11471142 }
11481143
11491144 /// Returns the internal `cc::Tool` for the C compiler.
11501145 fn cc_tool ( & self , target : TargetSelection ) -> Tool {
1151- self . cc . borrow ( ) [ & target] . clone ( )
1146+ self . cc [ & target] . clone ( )
11521147 }
11531148
11541149 /// Returns the internal `cc::Tool` for the C++ compiler.
11551150 fn cxx_tool ( & self , target : TargetSelection ) -> Tool {
1156- self . cxx . borrow ( ) [ & target] . clone ( )
1151+ self . cxx [ & target] . clone ( )
11571152 }
11581153
11591154 /// Returns C flags that `cc-rs` thinks should be enabled for the
@@ -1163,8 +1158,8 @@ impl Build {
11631158 return Vec :: new ( ) ;
11641159 }
11651160 let base = match c {
1166- CLang :: C => self . cc . borrow ( ) [ & target] . clone ( ) ,
1167- CLang :: Cxx => self . cxx . borrow ( ) [ & target] . clone ( ) ,
1161+ CLang :: C => self . cc [ & target] . clone ( ) ,
1162+ CLang :: Cxx => self . cxx [ & target] . clone ( ) ,
11681163 } ;
11691164
11701165 // Filter out -O and /O (the optimization flags) that we picked up
@@ -1217,23 +1212,23 @@ impl Build {
12171212 if self . config . dry_run ( ) {
12181213 return None ;
12191214 }
1220- self . ar . borrow ( ) . get ( & target) . cloned ( )
1215+ self . ar . get ( & target) . cloned ( )
12211216 }
12221217
12231218 /// Returns the path to the `ranlib` utility for the target specified.
12241219 fn ranlib ( & self , target : TargetSelection ) -> Option < PathBuf > {
12251220 if self . config . dry_run ( ) {
12261221 return None ;
12271222 }
1228- self . ranlib . borrow ( ) . get ( & target) . cloned ( )
1223+ self . ranlib . get ( & target) . cloned ( )
12291224 }
12301225
12311226 /// Returns the path to the C++ compiler for the target specified.
12321227 fn cxx ( & self , target : TargetSelection ) -> Result < PathBuf , String > {
12331228 if self . config . dry_run ( ) {
12341229 return Ok ( PathBuf :: new ( ) ) ;
12351230 }
1236- match self . cxx . borrow ( ) . get ( & target) {
1231+ match self . cxx . get ( & target) {
12371232 Some ( p) => Ok ( p. path ( ) . into ( ) ) ,
12381233 None => Err ( format ! ( "target `{target}` is not configured as a host, only as a target" ) ) ,
12391234 }
@@ -1250,7 +1245,7 @@ impl Build {
12501245 } else if target. contains ( "vxworks" ) {
12511246 // need to use CXX compiler as linker to resolve the exception functions
12521247 // that are only existed in CXX libraries
1253- Some ( self . cxx . borrow ( ) [ & target] . path ( ) . into ( ) )
1248+ Some ( self . cxx [ & target] . path ( ) . into ( ) )
12541249 } else if !self . config . is_host_target ( target)
12551250 && helpers:: use_host_linker ( target)
12561251 && !target. is_msvc ( )
0 commit comments