@@ -1903,13 +1903,19 @@ impl Build {
1903
1903
1904
1904
let tool_opt: Option < Tool > = self
1905
1905
. env_tool ( env)
1906
- . map ( |( tool, cc, args) | {
1906
+ . map ( |( tool, wrapper, args) | {
1907
+ // find the driver mode, if any
1908
+ const DRIVER_MODE : & str = "--driver-mode=" ;
1909
+ let driver_mode = args
1910
+ . iter ( )
1911
+ . find ( |a| a. starts_with ( DRIVER_MODE ) )
1912
+ . map ( |a| & a[ DRIVER_MODE . len ( ) ..] ) ;
1907
1913
// chop off leading/trailing whitespace to work around
1908
1914
// semi-buggy build scripts which are shared in
1909
1915
// makefiles/configure scripts (where spaces are far more
1910
1916
// lenient)
1911
- let mut t = Tool :: new ( PathBuf :: from ( tool. trim ( ) ) ) ;
1912
- if let Some ( cc) = cc {
1917
+ let mut t = Tool :: with_clang_driver ( PathBuf :: from ( tool. trim ( ) ) , driver_mode ) ;
1918
+ if let Some ( cc) = wrapper {
1913
1919
t. cc_wrapper_path = Some ( PathBuf :: from ( cc) ) ;
1914
1920
}
1915
1921
for arg in args {
@@ -2062,7 +2068,7 @@ impl Build {
2062
2068
Err ( _) => "nvcc" . into ( ) ,
2063
2069
Ok ( nvcc) => nvcc,
2064
2070
} ;
2065
- let mut nvcc_tool = Tool :: with_features ( PathBuf :: from ( nvcc) , self . cuda ) ;
2071
+ let mut nvcc_tool = Tool :: with_features ( PathBuf :: from ( nvcc) , None , self . cuda ) ;
2066
2072
nvcc_tool
2067
2073
. args
2068
2074
. push ( format ! ( "-ccbin={}" , tool. path. display( ) ) . into ( ) ) ;
@@ -2329,11 +2335,15 @@ impl Default for Build {
2329
2335
}
2330
2336
2331
2337
impl Tool {
2332
- fn new ( path : PathBuf ) -> Tool {
2333
- Tool :: with_features ( path, false )
2338
+ fn new ( path : PathBuf ) -> Self {
2339
+ Tool :: with_features ( path, None , false )
2334
2340
}
2335
2341
2336
- fn with_features ( path : PathBuf , cuda : bool ) -> Tool {
2342
+ fn with_clang_driver ( path : PathBuf , clang_driver : Option < & str > ) -> Self {
2343
+ Self :: with_features ( path, clang_driver, false )
2344
+ }
2345
+
2346
+ fn with_features ( path : PathBuf , clang_driver : Option < & str > , cuda : bool ) -> Self {
2337
2347
// Try to detect family of the tool from its name, falling back to Gnu.
2338
2348
let family = if let Some ( fname) = path. file_name ( ) . and_then ( |p| p. to_str ( ) ) {
2339
2349
if fname. contains ( "clang-cl" ) {
@@ -2345,13 +2355,17 @@ impl Tool {
2345
2355
{
2346
2356
ToolFamily :: Msvc { clang_cl : false }
2347
2357
} else if fname. contains ( "clang" ) {
2348
- ToolFamily :: Clang
2358
+ match clang_driver {
2359
+ Some ( "cl" ) => ToolFamily :: Msvc { clang_cl : true } ,
2360
+ _ => ToolFamily :: Clang ,
2361
+ }
2349
2362
} else {
2350
2363
ToolFamily :: Gnu
2351
2364
}
2352
2365
} else {
2353
2366
ToolFamily :: Gnu
2354
2367
} ;
2368
+
2355
2369
Tool {
2356
2370
path : path,
2357
2371
cc_wrapper_path : None ,
0 commit comments