@@ -291,6 +291,7 @@ pub struct Build {
291
291
apple_sdk_root_cache : Arc < Mutex < HashMap < String , OsString > > > ,
292
292
apple_versions_cache : Arc < Mutex < HashMap < String , String > > > ,
293
293
emit_rerun_if_env_changed : bool ,
294
+ cached_compiler_family : Arc < Mutex < HashMap < Box < Path > , ToolFamily > > > ,
294
295
}
295
296
296
297
/// Represents the types of errors that may occur while using cc-rs.
@@ -406,6 +407,7 @@ impl Build {
406
407
apple_sdk_root_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
407
408
apple_versions_cache : Arc :: new ( Mutex :: new ( HashMap :: new ( ) ) ) ,
408
409
emit_rerun_if_env_changed : true ,
410
+ cached_compiler_family : Arc :: default ( ) ,
409
411
}
410
412
}
411
413
@@ -2603,7 +2605,11 @@ impl Build {
2603
2605
2604
2606
fn get_base_compiler ( & self ) -> Result < Tool , Error > {
2605
2607
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
+ ) ) ;
2607
2613
}
2608
2614
let host = self . get_host ( ) ?;
2609
2615
let target = self . get_target ( ) ?;
@@ -2639,7 +2645,12 @@ impl Build {
2639
2645
// semi-buggy build scripts which are shared in
2640
2646
// makefiles/configure scripts (where spaces are far more
2641
2647
// 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
+ ) ;
2643
2654
if let Some ( cc_wrapper) = wrapper {
2644
2655
t. cc_wrapper_path = Some ( PathBuf :: from ( cc_wrapper) ) ;
2645
2656
}
@@ -2653,12 +2664,20 @@ impl Build {
2653
2664
let tool = if self . cpp { "em++" } else { "emcc" } ;
2654
2665
// Windows uses bat file so we have to be a bit more specific
2655
2666
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
+ ) ;
2657
2672
t. args . push ( "/c" . into ( ) ) ;
2658
2673
t. args . push ( format ! ( "{}.bat" , tool) . into ( ) ) ;
2659
2674
Some ( t)
2660
2675
} 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
+ ) )
2662
2681
}
2663
2682
} else {
2664
2683
None
@@ -2713,7 +2732,11 @@ impl Build {
2713
2732
default. to_string ( )
2714
2733
} ;
2715
2734
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
+ ) ;
2717
2740
if let Some ( cc_wrapper) = Self :: rustc_wrapper_fallback ( ) {
2718
2741
t. cc_wrapper_path = Some ( PathBuf :: from ( cc_wrapper) ) ;
2719
2742
}
@@ -2730,7 +2753,13 @@ impl Build {
2730
2753
Err ( _) => PathBuf :: from ( "nvcc" ) ,
2731
2754
Ok ( nvcc) => PathBuf :: from ( & * nvcc) ,
2732
2755
} ;
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
+ ) ;
2734
2763
nvcc_tool
2735
2764
. args
2736
2765
. push ( format ! ( "-ccbin={}" , tool. path. display( ) ) . into ( ) ) ;
0 commit comments