@@ -12,7 +12,7 @@ use rustc_metadata::fs::{copy_to_stdout, emit_wrapper_file, METADATA_FILENAME};
12
12
use rustc_middle:: middle:: debugger_visualizer:: DebuggerVisualizerFile ;
13
13
use rustc_middle:: middle:: dependency_format:: Linkage ;
14
14
use rustc_middle:: middle:: exported_symbols:: SymbolExportKind ;
15
- use rustc_session:: config:: { self , CFGuard , CrateType , DebugInfo , Strip } ;
15
+ use rustc_session:: config:: { self , CFGuard , CrateType , DebugInfo , OutFileName , Strip } ;
16
16
use rustc_session:: config:: { OutputFilenames , OutputType , PrintKind , SplitDwarfKind } ;
17
17
use rustc_session:: cstore:: DllImport ;
18
18
use rustc_session:: output:: { check_file_is_writeable, invalid_output_for_target, out_filename} ;
@@ -596,8 +596,10 @@ fn link_staticlib<'a>(
596
596
597
597
all_native_libs. extend_from_slice ( & codegen_results. crate_info . used_libraries ) ;
598
598
599
- if sess. opts . prints . iter ( ) . any ( |print| print. kind == PrintKind :: NativeStaticLibs ) {
600
- print_native_static_libs ( sess, & all_native_libs, & all_rust_dylibs) ;
599
+ for print in & sess. opts . prints {
600
+ if print. kind == PrintKind :: NativeStaticLibs {
601
+ print_native_static_libs ( sess, & print. out , & all_native_libs, & all_rust_dylibs) ;
602
+ }
601
603
}
602
604
603
605
Ok ( ( ) )
@@ -744,8 +746,11 @@ fn link_natively<'a>(
744
746
cmd. env_remove ( k. as_ref ( ) ) ;
745
747
}
746
748
747
- if sess. opts . prints . iter ( ) . any ( |print| print. kind == PrintKind :: LinkArgs ) {
748
- println ! ( "{:?}" , & cmd) ;
749
+ for print in & sess. opts . prints {
750
+ if print. kind == PrintKind :: LinkArgs {
751
+ let content = format ! ( "{:?}" , cmd) ;
752
+ print. out . overwrite ( & content, sess) ;
753
+ }
749
754
}
750
755
751
756
// May have not found libraries in the right formats.
@@ -1386,6 +1391,7 @@ enum RlibFlavor {
1386
1391
1387
1392
fn print_native_static_libs (
1388
1393
sess : & Session ,
1394
+ out : & OutFileName ,
1389
1395
all_native_libs : & [ NativeLib ] ,
1390
1396
all_rust_dylibs : & [ & Path ] ,
1391
1397
) {
@@ -1459,11 +1465,17 @@ fn print_native_static_libs(
1459
1465
lib_args. push ( format ! ( "-l{}" , lib) ) ;
1460
1466
}
1461
1467
}
1462
- if !lib_args. is_empty ( ) {
1463
- sess. emit_note ( errors:: StaticLibraryNativeArtifacts ) ;
1464
- // Prefix for greppability
1465
- // Note: This must not be translated as tools are allowed to depend on this exact string.
1466
- sess. note_without_error ( format ! ( "native-static-libs: {}" , & lib_args. join( " " ) ) ) ;
1468
+
1469
+ match out {
1470
+ OutFileName :: Real ( _) => out. overwrite ( & lib_args. join ( " " ) , sess) ,
1471
+ OutFileName :: Stdout => {
1472
+ if !lib_args. is_empty ( ) {
1473
+ sess. emit_note ( errors:: StaticLibraryNativeArtifacts ) ;
1474
+ // Prefix for greppability
1475
+ // Note: This must not be translated as tools are allowed to depend on this exact string.
1476
+ sess. note_without_error ( format ! ( "native-static-libs: {}" , & lib_args. join( " " ) ) ) ;
1477
+ }
1478
+ }
1467
1479
}
1468
1480
}
1469
1481
0 commit comments