@@ -6,7 +6,6 @@ use crate::errors::{
6
6
use crate :: llvm;
7
7
use libc:: c_int;
8
8
use rustc_codegen_ssa:: base:: wants_wasm_eh;
9
- use rustc_codegen_ssa:: traits:: PrintBackendInfo ;
10
9
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
11
10
use rustc_data_structures:: small_c_str:: SmallCStr ;
12
11
use rustc_fs_util:: path_to_c_string;
@@ -18,6 +17,7 @@ use rustc_target::spec::{MergeFunctions, PanicStrategy};
18
17
use rustc_target:: target_features:: RUSTC_SPECIFIC_FEATURES ;
19
18
20
19
use std:: ffi:: { c_char, c_void, CStr , CString } ;
20
+ use std:: fmt:: Write ;
21
21
use std:: path:: Path ;
22
22
use std:: ptr;
23
23
use std:: slice;
@@ -372,7 +372,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
372
372
ret
373
373
}
374
374
375
- fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
375
+ fn print_target_features ( out : & mut String , sess : & Session , tm : & llvm:: TargetMachine ) {
376
376
let mut llvm_target_features = llvm_target_features ( tm) ;
377
377
let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
378
378
let mut rustc_target_features = sess
@@ -412,24 +412,26 @@ fn print_target_features(out: &mut dyn PrintBackendInfo, sess: &Session, tm: &ll
412
412
. max ( )
413
413
. unwrap_or ( 0 ) ;
414
414
415
- writeln ! ( out, "Features supported by rustc for this target:" ) ;
415
+ writeln ! ( out, "Features supported by rustc for this target:" ) . unwrap ( ) ;
416
416
for ( feature, desc) in & rustc_target_features {
417
- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
417
+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
418
418
}
419
- writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) ;
419
+ writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) . unwrap ( ) ;
420
420
for ( feature, desc) in & llvm_target_features {
421
- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
421
+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
422
422
}
423
423
if llvm_target_features. is_empty ( ) {
424
- writeln ! ( out, " Target features listing is not supported by this LLVM version." ) ;
424
+ writeln ! ( out, " Target features listing is not supported by this LLVM version." )
425
+ . unwrap ( ) ;
425
426
}
426
- writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) ;
427
- writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
428
- writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
429
- writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
427
+ writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) . unwrap ( ) ;
428
+ writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " )
429
+ . unwrap ( ) ;
430
+ writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) . unwrap ( ) ;
431
+ writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) . unwrap ( ) ;
430
432
}
431
433
432
- pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut dyn PrintBackendInfo , sess : & Session ) {
434
+ pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut String , sess : & Session ) {
433
435
require_inited ( ) ;
434
436
let tm = create_informational_target_machine ( sess) ;
435
437
match req. kind {
@@ -440,9 +442,9 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess
440
442
let cpu_cstring = CString :: new ( handle_native ( sess. target . cpu . as_ref ( ) ) )
441
443
. unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
442
444
unsafe extern "C" fn callback ( out : * mut c_void , string : * const c_char , len : usize ) {
443
- let out = & mut * ( out as * mut & mut dyn PrintBackendInfo ) ;
445
+ let out = & mut * ( out as * mut & mut String ) ;
444
446
let bytes = slice:: from_raw_parts ( string as * const u8 , len) ;
445
- write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) ;
447
+ write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) . unwrap ( ) ;
446
448
}
447
449
unsafe {
448
450
llvm:: LLVMRustPrintTargetCPUs (
0 commit comments