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 } ;
@@ -190,10 +190,10 @@ pub struct Build {
190
190
191
191
// Runtime state filled in later on
192
192
// 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 > ,
197
197
// Miscellaneous
198
198
// allow bidirectional lookups: both name -> path and path -> name
199
199
crates : HashMap < String , Crate > ,
@@ -464,10 +464,10 @@ impl Build {
464
464
enzyme_info,
465
465
in_tree_llvm_info,
466
466
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 ( ) ,
471
471
crates : HashMap :: new ( ) ,
472
472
crate_paths : HashMap :: new ( ) ,
473
473
is_sudo,
@@ -493,7 +493,7 @@ impl Build {
493
493
}
494
494
495
495
build. verbose ( || println ! ( "finding compilers" ) ) ;
496
- utils:: cc_detect:: find ( & build) ;
496
+ utils:: cc_detect:: fill_compilers ( & mut build) ;
497
497
// When running `setup`, the profile is about to change, so any requirements we have now may
498
498
// be different on the next invocation. Don't check for them until the next time x.py is
499
499
// 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 {
1133
1133
if self . config . dry_run ( ) {
1134
1134
return PathBuf :: new ( ) ;
1135
1135
}
1136
- self . cc . borrow ( ) [ & target] . path ( ) . into ( )
1136
+ self . cc [ & target] . path ( ) . into ( )
1137
1137
}
1138
1138
1139
1139
/// Returns the internal `cc::Tool` for the C compiler.
1140
1140
fn cc_tool ( & self , target : TargetSelection ) -> Tool {
1141
- self . cc . borrow ( ) [ & target] . clone ( )
1141
+ self . cc [ & target] . clone ( )
1142
1142
}
1143
1143
1144
1144
/// Returns the internal `cc::Tool` for the C++ compiler.
1145
1145
fn cxx_tool ( & self , target : TargetSelection ) -> Tool {
1146
- self . cxx . borrow ( ) [ & target] . clone ( )
1146
+ self . cxx [ & target] . clone ( )
1147
1147
}
1148
1148
1149
1149
/// Returns C flags that `cc-rs` thinks should be enabled for the
@@ -1153,8 +1153,8 @@ impl Build {
1153
1153
return Vec :: new ( ) ;
1154
1154
}
1155
1155
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 ( ) ,
1158
1158
} ;
1159
1159
1160
1160
// Filter out -O and /O (the optimization flags) that we picked up
@@ -1207,23 +1207,23 @@ impl Build {
1207
1207
if self . config . dry_run ( ) {
1208
1208
return None ;
1209
1209
}
1210
- self . ar . borrow ( ) . get ( & target) . cloned ( )
1210
+ self . ar . get ( & target) . cloned ( )
1211
1211
}
1212
1212
1213
1213
/// Returns the path to the `ranlib` utility for the target specified.
1214
1214
fn ranlib ( & self , target : TargetSelection ) -> Option < PathBuf > {
1215
1215
if self . config . dry_run ( ) {
1216
1216
return None ;
1217
1217
}
1218
- self . ranlib . borrow ( ) . get ( & target) . cloned ( )
1218
+ self . ranlib . get ( & target) . cloned ( )
1219
1219
}
1220
1220
1221
1221
/// Returns the path to the C++ compiler for the target specified.
1222
1222
fn cxx ( & self , target : TargetSelection ) -> Result < PathBuf , String > {
1223
1223
if self . config . dry_run ( ) {
1224
1224
return Ok ( PathBuf :: new ( ) ) ;
1225
1225
}
1226
- match self . cxx . borrow ( ) . get ( & target) {
1226
+ match self . cxx . get ( & target) {
1227
1227
Some ( p) => Ok ( p. path ( ) . into ( ) ) ,
1228
1228
None => Err ( format ! ( "target `{target}` is not configured as a host, only as a target" ) ) ,
1229
1229
}
@@ -1240,7 +1240,7 @@ impl Build {
1240
1240
} else if target. contains ( "vxworks" ) {
1241
1241
// need to use CXX compiler as linker to resolve the exception functions
1242
1242
// that are only existed in CXX libraries
1243
- Some ( self . cxx . borrow ( ) [ & target] . path ( ) . into ( ) )
1243
+ Some ( self . cxx [ & target] . path ( ) . into ( ) )
1244
1244
} else if !self . config . is_host_target ( target)
1245
1245
&& helpers:: use_host_linker ( target)
1246
1246
&& !target. is_msvc ( )
0 commit comments