@@ -8,6 +8,7 @@ use libc::c_int;
8
8
use rustc_codegen_ssa:: target_features:: {
9
9
supported_target_features, tied_target_features, RUSTC_SPECIFIC_FEATURES ,
10
10
} ;
11
+ use rustc_codegen_ssa:: traits:: PrintBackendInfo ;
11
12
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
12
13
use rustc_data_structures:: small_c_str:: SmallCStr ;
13
14
use rustc_fs_util:: path_to_c_string;
@@ -350,7 +351,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
350
351
ret
351
352
}
352
353
353
- fn print_target_features ( sess : & Session , tm : & llvm:: TargetMachine ) {
354
+ fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
354
355
let mut llvm_target_features = llvm_target_features ( tm) ;
355
356
let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
356
357
let mut rustc_target_features = supported_target_features ( sess)
@@ -383,24 +384,24 @@ fn print_target_features(sess: &Session, tm: &llvm::TargetMachine) {
383
384
. max ( )
384
385
. unwrap_or ( 0 ) ;
385
386
386
- println ! ( "Features supported by rustc for this target:" ) ;
387
+ writeln ! ( out , "Features supported by rustc for this target:" ) ;
387
388
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) ;
389
390
}
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:" ) ;
391
392
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) ;
393
394
}
394
395
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." ) ;
396
397
}
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 " ) ;
401
402
}
402
403
403
- pub ( crate ) fn print ( req : & PrintRequest , sess : & Session ) {
404
+ pub ( crate ) fn print ( req : & PrintRequest , out : & mut dyn PrintBackendInfo , sess : & Session ) {
404
405
require_inited ( ) ;
405
406
let tm = create_informational_target_machine ( sess) ;
406
407
match req. kind {
@@ -412,7 +413,7 @@ pub(crate) fn print(req: &PrintRequest, sess: &Session) {
412
413
. unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
413
414
unsafe { llvm:: LLVMRustPrintTargetCPUs ( tm, cpu_cstring. as_ptr ( ) ) } ;
414
415
}
415
- PrintKind :: TargetFeatures => print_target_features ( sess, tm) ,
416
+ PrintKind :: TargetFeatures => print_target_features ( out , sess, tm) ,
416
417
_ => bug ! ( "rustc_codegen_llvm can't handle print request: {:?}" , req) ,
417
418
}
418
419
}
0 commit comments