@@ -175,6 +175,7 @@ pub struct Tool {
175175 env : Vec < ( OsString , OsString ) > ,
176176 family : ToolFamily ,
177177 cuda : bool ,
178+ removed_args : Vec < OsString > ,
178179}
179180
180181/// Represents the family of tools this tool belongs to.
@@ -259,6 +260,10 @@ impl ToolFamily {
259260 ToolFamily :: Gnu | ToolFamily :: Clang => "-Xcompiler" ,
260261 }
261262 }
263+
264+ fn verbose_stderr ( & self ) -> bool {
265+ * self == ToolFamily :: Clang
266+ }
262267}
263268
264269/// Represents an object.
@@ -422,7 +427,14 @@ impl Build {
422427 . debug ( false )
423428 . cpp ( self . cpp )
424429 . 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+
426438 let mut cmd = compiler. to_command ( ) ;
427439 let is_arm = target. contains ( "aarch64" ) || target. contains ( "arm" ) ;
428440 command_add_output_file ( & mut cmd, & obj, target. contains ( "msvc" ) , false , is_arm) ;
@@ -1960,9 +1972,15 @@ impl Tool {
19601972 env : Vec :: new ( ) ,
19611973 family : family,
19621974 cuda : cuda,
1975+ removed_args : Vec :: new ( ) ,
19631976 }
19641977 }
19651978
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+
19661984 /// Add a flag, and optionally prepend the NVCC wrapper flag "-Xcompiler".
19671985 ///
19681986 /// Currently this is only used for compiling CUDA sources, since NVCC only
@@ -1990,7 +2008,7 @@ impl Tool {
19902008 None => Command :: new ( & self . path ) ,
19912009 } ;
19922010 cmd. args ( & self . cc_wrapper_args ) ;
1993- cmd. args ( & self . args ) ;
2011+ cmd. args ( self . args . iter ( ) . filter ( |a| ! self . removed_args . contains ( a ) ) ) ;
19942012 for & ( ref k, ref v) in self . env . iter ( ) {
19952013 cmd. env ( k, v) ;
19962014 }
0 commit comments