@@ -175,6 +175,7 @@ pub struct Tool {
175
175
env : Vec < ( OsString , OsString ) > ,
176
176
family : ToolFamily ,
177
177
cuda : bool ,
178
+ removed_args : Vec < OsString > ,
178
179
}
179
180
180
181
/// Represents the family of tools this tool belongs to.
@@ -259,6 +260,10 @@ impl ToolFamily {
259
260
ToolFamily :: Gnu | ToolFamily :: Clang => "-Xcompiler" ,
260
261
}
261
262
}
263
+
264
+ fn verbose_stderr ( & self ) -> bool {
265
+ * self == ToolFamily :: Clang
266
+ }
262
267
}
263
268
264
269
/// Represents an object.
@@ -422,7 +427,14 @@ impl Build {
422
427
. debug ( false )
423
428
. cpp ( self . cpp )
424
429
. cuda ( self . cuda ) ;
425
- let compiler = cfg. try_get_compiler ( ) ?;
430
+ let mut compiler = cfg. try_get_compiler ( ) ?;
431
+
432
+ // Clang uses stderr for verbose output, which yields a false positive
433
+ // result if the CFLAGS/CXXFLAGS include -v to aid in debugging.
434
+ if compiler. family . verbose_stderr ( ) {
435
+ compiler. remove_arg ( "-v" . into ( ) ) ;
436
+ }
437
+
426
438
let mut cmd = compiler. to_command ( ) ;
427
439
let is_arm = target. contains ( "aarch64" ) || target. contains ( "arm" ) ;
428
440
command_add_output_file ( & mut cmd, & obj, target. contains ( "msvc" ) , false , is_arm) ;
@@ -1960,9 +1972,15 @@ impl Tool {
1960
1972
env : Vec :: new ( ) ,
1961
1973
family : family,
1962
1974
cuda : cuda,
1975
+ removed_args : Vec :: new ( ) ,
1963
1976
}
1964
1977
}
1965
1978
1979
+ /// Add an argument to be stripped from the final command arguments.
1980
+ fn remove_arg ( & mut self , flag : OsString ) {
1981
+ self . removed_args . push ( flag) ;
1982
+ }
1983
+
1966
1984
/// Add a flag, and optionally prepend the NVCC wrapper flag "-Xcompiler".
1967
1985
///
1968
1986
/// Currently this is only used for compiling CUDA sources, since NVCC only
@@ -1990,7 +2008,7 @@ impl Tool {
1990
2008
None => Command :: new ( & self . path ) ,
1991
2009
} ;
1992
2010
cmd. args ( & self . cc_wrapper_args ) ;
1993
- cmd. args ( & self . args ) ;
2011
+ cmd. args ( self . args . iter ( ) . filter ( |a| ! self . removed_args . contains ( a ) ) ) ;
1994
2012
for & ( ref k, ref v) in self . env . iter ( ) {
1995
2013
cmd. env ( k, v) ;
1996
2014
}
0 commit comments