@@ -721,6 +721,14 @@ fn link_dwarf_object<'a>(
721
721
}
722
722
}
723
723
724
+ #[ derive( Diagnostic ) ]
725
+ #[ diag( codegen_ssa_linker_output) ]
726
+ /// Translating this is kind of useless. We don't pass translation flags to the linker, so we'd just
727
+ /// end up with inconsistent languages within the same diagnostic.
728
+ struct LinkerOutput {
729
+ inner : String ,
730
+ }
731
+
724
732
/// Create a dynamic library or executable.
725
733
///
726
734
/// This will invoke the system linker/cc to create the resulting file. This links to all upstream
@@ -972,8 +980,22 @@ fn link_natively<'a>(
972
980
973
981
sess. dcx ( ) . abort_if_errors ( ) ;
974
982
}
975
- info ! ( "linker stderr:\n {}" , escape_string( & prog. stderr) ) ;
976
- info ! ( "linker stdout:\n {}" , escape_string( & prog. stdout) ) ;
983
+
984
+ if !prog. stderr . is_empty ( ) {
985
+ // We already print `warning:` at the start of the diagnostic. Remove it from the linker output if present.
986
+ let stderr = escape_string ( & prog. stderr ) ;
987
+ debug ! ( "original stderr: {stderr}" ) ;
988
+ let stderr = stderr
989
+ . strip_prefix ( "warning: " )
990
+ . unwrap_or ( & stderr)
991
+ . replace ( ": warning: " , ": " ) ;
992
+ sess. dcx ( ) . emit_warn ( LinkerOutput { inner : format ! ( "linker stderr: {stderr}" ) } ) ;
993
+ }
994
+ if !prog. stdout . is_empty ( ) && sess. opts . verbose {
995
+ sess. dcx ( ) . emit_warn ( LinkerOutput {
996
+ inner : format ! ( "linker stdout: {}" , escape_string( & prog. stdout) ) ,
997
+ } ) ;
998
+ }
977
999
}
978
1000
Err ( e) => {
979
1001
let linker_not_found = e. kind ( ) == io:: ErrorKind :: NotFound ;
0 commit comments