17
17
//! also check out the `src/bootstrap/README.md` file for more information.
18
18
#![ cfg_attr( test, allow( unused) ) ]
19
19
20
- use std:: cell:: { Cell , RefCell } ;
20
+ use std:: cell:: Cell ;
21
21
use std:: collections:: { BTreeSet , HashMap , HashSet } ;
22
22
use std:: fmt:: Display ;
23
23
use std:: path:: { Path , PathBuf } ;
@@ -189,10 +189,12 @@ pub struct Build {
189
189
190
190
// Runtime state filled in later on
191
191
// 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
+
196
198
// Miscellaneous
197
199
// allow bidirectional lookups: both name -> path and path -> name
198
200
crates : HashMap < String , Crate > ,
@@ -466,10 +468,11 @@ impl Build {
466
468
enzyme_info,
467
469
in_tree_llvm_info,
468
470
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) ,
473
476
crates : HashMap :: new ( ) ,
474
477
crate_paths : HashMap :: new ( ) ,
475
478
is_sudo,
@@ -498,7 +501,7 @@ impl Build {
498
501
}
499
502
500
503
build. verbose ( || println ! ( "finding compilers" ) ) ;
501
- utils:: cc_detect:: find ( & build) ;
504
+ utils:: cc_detect:: fill_compilers ( & mut build) ;
502
505
// When running `setup`, the profile is about to change, so any requirements we have now may
503
506
// be different on the next invocation. Don't check for them until the next time x.py is
504
507
// 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 {
593
596
}
594
597
}
595
598
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
-
604
599
/// If any submodule has been initialized already, sync it unconditionally.
605
600
/// This avoids contributors checking in a submodule change by accident.
606
601
fn update_existing_submodules ( & self ) {
@@ -1143,17 +1138,17 @@ impl Build {
1143
1138
if self . config . dry_run ( ) {
1144
1139
return PathBuf :: new ( ) ;
1145
1140
}
1146
- self . cc . borrow ( ) [ & target] . path ( ) . into ( )
1141
+ self . cc [ & target] . path ( ) . into ( )
1147
1142
}
1148
1143
1149
1144
/// Returns the internal `cc::Tool` for the C compiler.
1150
1145
fn cc_tool ( & self , target : TargetSelection ) -> Tool {
1151
- self . cc . borrow ( ) [ & target] . clone ( )
1146
+ self . cc [ & target] . clone ( )
1152
1147
}
1153
1148
1154
1149
/// Returns the internal `cc::Tool` for the C++ compiler.
1155
1150
fn cxx_tool ( & self , target : TargetSelection ) -> Tool {
1156
- self . cxx . borrow ( ) [ & target] . clone ( )
1151
+ self . cxx [ & target] . clone ( )
1157
1152
}
1158
1153
1159
1154
/// Returns C flags that `cc-rs` thinks should be enabled for the
@@ -1163,8 +1158,8 @@ impl Build {
1163
1158
return Vec :: new ( ) ;
1164
1159
}
1165
1160
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 ( ) ,
1168
1163
} ;
1169
1164
1170
1165
// Filter out -O and /O (the optimization flags) that we picked up
@@ -1217,23 +1212,23 @@ impl Build {
1217
1212
if self . config . dry_run ( ) {
1218
1213
return None ;
1219
1214
}
1220
- self . ar . borrow ( ) . get ( & target) . cloned ( )
1215
+ self . ar . get ( & target) . cloned ( )
1221
1216
}
1222
1217
1223
1218
/// Returns the path to the `ranlib` utility for the target specified.
1224
1219
fn ranlib ( & self , target : TargetSelection ) -> Option < PathBuf > {
1225
1220
if self . config . dry_run ( ) {
1226
1221
return None ;
1227
1222
}
1228
- self . ranlib . borrow ( ) . get ( & target) . cloned ( )
1223
+ self . ranlib . get ( & target) . cloned ( )
1229
1224
}
1230
1225
1231
1226
/// Returns the path to the C++ compiler for the target specified.
1232
1227
fn cxx ( & self , target : TargetSelection ) -> Result < PathBuf , String > {
1233
1228
if self . config . dry_run ( ) {
1234
1229
return Ok ( PathBuf :: new ( ) ) ;
1235
1230
}
1236
- match self . cxx . borrow ( ) . get ( & target) {
1231
+ match self . cxx . get ( & target) {
1237
1232
Some ( p) => Ok ( p. path ( ) . into ( ) ) ,
1238
1233
None => Err ( format ! ( "target `{target}` is not configured as a host, only as a target" ) ) ,
1239
1234
}
@@ -1250,7 +1245,7 @@ impl Build {
1250
1245
} else if target. contains ( "vxworks" ) {
1251
1246
// need to use CXX compiler as linker to resolve the exception functions
1252
1247
// that are only existed in CXX libraries
1253
- Some ( self . cxx . borrow ( ) [ & target] . path ( ) . into ( ) )
1248
+ Some ( self . cxx [ & target] . path ( ) . into ( ) )
1254
1249
} else if !self . config . is_host_target ( target)
1255
1250
&& helpers:: use_host_linker ( target)
1256
1251
&& !target. is_msvc ( )
0 commit comments