@@ -8,6 +8,7 @@ use libc::c_int;
88use rustc_codegen_ssa:: target_features:: {
99 supported_target_features, tied_target_features, RUSTC_SPECIFIC_FEATURES ,
1010} ;
11+ use rustc_codegen_ssa:: traits:: PrintBackendInfo ;
1112use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
1213use rustc_data_structures:: small_c_str:: SmallCStr ;
1314use rustc_fs_util:: path_to_c_string;
@@ -350,7 +351,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
350351 ret
351352}
352353
353- fn print_target_features ( sess : & Session , tm : & llvm:: TargetMachine ) {
354+ fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
354355 let mut llvm_target_features = llvm_target_features ( tm) ;
355356 let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
356357 let mut rustc_target_features = supported_target_features ( sess)
@@ -383,24 +384,24 @@ fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
383384 . max ( )
384385 . unwrap_or ( 0 ) ;
385386
386- println ! ( "Features supported by rustc for this target:" ) ;
387+ writeln ! ( out , "Features supported by rustc for this target:" ) ;
387388 for ( feature, desc) in & rustc_target_features {
388- println ! ( " {1:0$} - {2}." , max_feature_len, feature, desc) ;
389+ writeln ! ( out , " {1:0$} - {2}." , max_feature_len, feature, desc) ;
389390 }
390- println ! ( "\n Code-generation features supported by LLVM for this target:" ) ;
391+ writeln ! ( out , "\n Code-generation features supported by LLVM for this target:" ) ;
391392 for ( feature, desc) in & llvm_target_features {
392- println ! ( " {1:0$} - {2}." , max_feature_len, feature, desc) ;
393+ writeln ! ( out , " {1:0$} - {2}." , max_feature_len, feature, desc) ;
393394 }
394395 if llvm_target_features. is_empty ( ) {
395- println ! ( " Target features listing is not supported by this LLVM version." ) ;
396+ writeln ! ( out , " Target features listing is not supported by this LLVM version." ) ;
396397 }
397- println ! ( "\n Use +feature to enable a feature, or -feature to disable it." ) ;
398- println ! ( "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
399- println ! ( "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
400- println ! ( "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
398+ writeln ! ( out , "\n Use +feature to enable a feature, or -feature to disable it." ) ;
399+ writeln ! ( out , "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
400+ writeln ! ( out , "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
401+ writeln ! ( out , "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
401402}
402403
403- pub ( crate ) fn print ( req : & PrintRequest , sess : & Session ) {
404+ pub ( crate ) fn print ( req : & PrintRequest , out : & mut dyn PrintBackendInfo , sess : & Session ) {
404405 require_inited ( ) ;
405406 let tm = create_informational_target_machine ( sess) ;
406407 match req. kind {
@@ -412,7 +413,7 @@ pub(crate) fn print(req: &PrintRequest, sess: &Session) {
412413 . unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
413414 unsafe { llvm:: LLVMRustPrintTargetCPUs ( tm, cpu_cstring. as_ptr ( ) ) } ;
414415 }
415- PrintKind :: TargetFeatures => print_target_features ( sess, tm) ,
416+ PrintKind :: TargetFeatures => print_target_features ( out , sess, tm) ,
416417 _ => bug ! ( "rustc_codegen_llvm can't handle print request: {:?}" , req) ,
417418 }
418419}
0 commit comments