@@ -291,6 +291,7 @@ pub struct Build {
291291 apple_sdk_root_cache : Arc < Mutex < HashMap < String , OsString > > > ,
292292 apple_versions_cache : Arc < Mutex < HashMap < String , String > > > ,
293293 emit_rerun_if_env_changed : bool ,
294+ cached_compiler_family : Arc < Mutex < HashMap < Box < Path > , ToolFamily > > > ,
294295}
295296
296297/// Represents the types of errors that may occur while using cc-rs.
@@ -406,6 +407,7 @@ impl Build {
406407 apple_sdk_root_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
407408 apple_versions_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
408409 emit_rerun_if_env_changed : true ,
410+ cached_compiler_family : Arc :: default ( ) ,
409411 }
410412 }
411413
@@ -2603,7 +2605,11 @@ impl Build {
26032605
26042606 fn get_base_compiler ( & self ) -> Result < Tool , Error > {
26052607 if let Some ( c) = & self . compiler {
2606- return Ok ( Tool :: new ( ( * * c) . to_owned ( ) , & self . cargo_output ) ) ;
2608+ return Ok ( Tool :: new (
2609+ ( * * c) . to_owned ( ) ,
2610+ & self . cached_compiler_family ,
2611+ & self . cargo_output ,
2612+ ) ) ;
26072613 }
26082614 let host = self . get_host ( ) ?;
26092615 let target = self . get_target ( ) ?;
@@ -2639,7 +2645,12 @@ impl Build {
26392645 // semi-buggy build scripts which are shared in
26402646 // makefiles/configure scripts (where spaces are far more
26412647 // lenient)
2642- let mut t = Tool :: with_clang_driver ( tool, driver_mode, & self . cargo_output ) ;
2648+ let mut t = Tool :: with_clang_driver (
2649+ tool,
2650+ driver_mode,
2651+ & self . cached_compiler_family ,
2652+ & self . cargo_output ,
2653+ ) ;
26432654 if let Some ( cc_wrapper) = wrapper {
26442655 t. cc_wrapper_path = Some ( PathBuf :: from ( cc_wrapper) ) ;
26452656 }
@@ -2653,12 +2664,20 @@ impl Build {
26532664 let tool = if self . cpp { "em++" } else { "emcc" } ;
26542665 // Windows uses bat file so we have to be a bit more specific
26552666 if cfg ! ( windows) {
2656- let mut t = Tool :: new ( PathBuf :: from ( "cmd" ) , & self . cargo_output ) ;
2667+ let mut t = Tool :: new (
2668+ PathBuf :: from ( "cmd" ) ,
2669+ & self . cached_compiler_family ,
2670+ & self . cargo_output ,
2671+ ) ;
26572672 t. args . push ( "/c" . into ( ) ) ;
26582673 t. args . push ( format ! ( "{}.bat" , tool) . into ( ) ) ;
26592674 Some ( t)
26602675 } else {
2661- Some ( Tool :: new ( PathBuf :: from ( tool) , & self . cargo_output ) )
2676+ Some ( Tool :: new (
2677+ PathBuf :: from ( tool) ,
2678+ & self . cached_compiler_family ,
2679+ & self . cargo_output ,
2680+ ) )
26622681 }
26632682 } else {
26642683 None
@@ -2713,7 +2732,11 @@ impl Build {
27132732 default. to_string ( )
27142733 } ;
27152734
2716- let mut t = Tool :: new ( PathBuf :: from ( compiler) , & self . cargo_output ) ;
2735+ let mut t = Tool :: new (
2736+ PathBuf :: from ( compiler) ,
2737+ & self . cached_compiler_family ,
2738+ & self . cargo_output ,
2739+ ) ;
27172740 if let Some ( cc_wrapper) = Self :: rustc_wrapper_fallback ( ) {
27182741 t. cc_wrapper_path = Some ( PathBuf :: from ( cc_wrapper) ) ;
27192742 }
@@ -2730,7 +2753,13 @@ impl Build {
27302753 Err ( _) => PathBuf :: from ( "nvcc" ) ,
27312754 Ok ( nvcc) => PathBuf :: from ( & * nvcc) ,
27322755 } ;
2733- let mut nvcc_tool = Tool :: with_features ( nvcc, None , self . cuda , & self . cargo_output ) ;
2756+ let mut nvcc_tool = Tool :: with_features (
2757+ nvcc,
2758+ None ,
2759+ self . cuda ,
2760+ & self . cached_compiler_family ,
2761+ & self . cargo_output ,
2762+ ) ;
27342763 nvcc_tool
27352764 . args
27362765 . push ( format ! ( "-ccbin={}" , tool. path. display( ) ) . into ( ) ) ;
0 commit comments