@@ -46,24 +46,24 @@ impl Tool {
4646 ) -> Self {
4747 Self :: with_features (
4848 path,
49- None ,
49+ vec ! [ ] ,
5050 false ,
5151 cached_compiler_family,
5252 cargo_output,
5353 out_dir,
5454 )
5555 }
5656
57- pub ( crate ) fn with_clang_driver (
57+ pub ( crate ) fn with_args (
5858 path : PathBuf ,
59- clang_driver : Option < & str > ,
59+ args : Vec < String > ,
6060 cached_compiler_family : & RwLock < HashMap < Box < Path > , ToolFamily > > ,
6161 cargo_output : & CargoOutput ,
6262 out_dir : Option < & Path > ,
6363 ) -> Self {
6464 Self :: with_features (
6565 path,
66- clang_driver ,
66+ args ,
6767 false ,
6868 cached_compiler_family,
6969 cargo_output,
@@ -88,7 +88,7 @@ impl Tool {
8888
8989 pub ( crate ) fn with_features (
9090 path : PathBuf ,
91- clang_driver : Option < & str > ,
91+ args : Vec < String > ,
9292 cuda : bool ,
9393 cached_compiler_family : & RwLock < HashMap < Box < Path > , ToolFamily > > ,
9494 cargo_output : & CargoOutput ,
@@ -235,12 +235,18 @@ impl Tool {
235235 Some ( fname) if fname. ends_with ( "cl" ) || fname == "cl.exe" => {
236236 ToolFamily :: Msvc { clang_cl : false }
237237 }
238- Some ( fname) if fname. contains ( "clang" ) => match clang_driver {
239- Some ( "cl" ) => ToolFamily :: Msvc { clang_cl : true } ,
240- _ => ToolFamily :: Clang {
241- zig_cc : is_zig_cc ( & path, cargo_output) ,
242- } ,
243- } ,
238+ Some ( fname) if fname. contains ( "clang" ) => {
239+ let is_clang_cl = args
240+ . iter ( )
241+ . find_map ( |a| a. strip_prefix ( "--driver-mode=" ) == Some ( "cl" ) )
242+ if is_clang_cl {
243+ ToolFamily :: Msvc { clang_cl : true }
244+ } else {
245+ ToolFamily :: Clang {
246+ zig_cc : is_zig_cc ( & path, cargo_output) ,
247+ }
248+ }
249+ }
244250 Some ( fname) if fname. contains ( "zig" ) => ToolFamily :: Clang { zig_cc : true } ,
245251 _ => ToolFamily :: Gnu ,
246252 }
0 commit comments