@@ -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;
@@ -371,7 +371,7 @@ fn llvm_target_features(tm: &llvm::TargetMachine) -> Vec<(&str, &str)> {
371
371
ret
372
372
}
373
373
374
- fn print_target_features ( out : & mut dyn PrintBackendInfo , sess : & Session , tm : & llvm:: TargetMachine ) {
374
+ fn print_target_features ( out : & mut String , sess : & Session , tm : & llvm:: TargetMachine ) {
375
375
let mut llvm_target_features = llvm_target_features ( tm) ;
376
376
let mut known_llvm_target_features = FxHashSet :: < & ' static str > :: default ( ) ;
377
377
let mut rustc_target_features = sess
@@ -406,24 +406,26 @@ fn print_target_features(out: &mut dyn PrintBackendInfo, sess: &Session, tm: &ll
406
406
. max ( )
407
407
. unwrap_or ( 0 ) ;
408
408
409
- writeln ! ( out, "Features supported by rustc for this target:" ) ;
409
+ writeln ! ( out, "Features supported by rustc for this target:" ) . unwrap ( ) ;
410
410
for ( feature, desc) in & rustc_target_features {
411
- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
411
+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
412
412
}
413
- writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) ;
413
+ writeln ! ( out, "\n Code-generation features supported by LLVM for this target:" ) . unwrap ( ) ;
414
414
for ( feature, desc) in & llvm_target_features {
415
- writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) ;
415
+ writeln ! ( out, " {feature:max_feature_len$} - {desc}." ) . unwrap ( ) ;
416
416
}
417
417
if llvm_target_features. is_empty ( ) {
418
- writeln ! ( out, " Target features listing is not supported by this LLVM version." ) ;
418
+ writeln ! ( out, " Target features listing is not supported by this LLVM version." )
419
+ . unwrap ( ) ;
419
420
}
420
- writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) ;
421
- writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " ) ;
422
- writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) ;
423
- writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) ;
421
+ writeln ! ( out, "\n Use +feature to enable a feature, or -feature to disable it." ) . unwrap ( ) ;
422
+ writeln ! ( out, "For example, rustc -C target-cpu=mycpu -C target-feature=+feature1,-feature2\n " )
423
+ . unwrap ( ) ;
424
+ writeln ! ( out, "Code-generation features cannot be used in cfg or #[target_feature]," ) . unwrap ( ) ;
425
+ writeln ! ( out, "and may be renamed or removed in a future version of LLVM or rustc.\n " ) . unwrap ( ) ;
424
426
}
425
427
426
- pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut dyn PrintBackendInfo , sess : & Session ) {
428
+ pub ( crate ) fn print ( req : & PrintRequest , mut out : & mut String , sess : & Session ) {
427
429
require_inited ( ) ;
428
430
let tm = create_informational_target_machine ( sess) ;
429
431
match req. kind {
@@ -434,9 +436,9 @@ pub(crate) fn print(req: &PrintRequest, mut out: &mut dyn PrintBackendInfo, sess
434
436
let cpu_cstring = CString :: new ( handle_native ( sess. target . cpu . as_ref ( ) ) )
435
437
. unwrap_or_else ( |e| bug ! ( "failed to convert to cstring: {}" , e) ) ;
436
438
unsafe extern "C" fn callback ( out : * mut c_void , string : * const c_char , len : usize ) {
437
- let out = & mut * ( out as * mut & mut dyn PrintBackendInfo ) ;
439
+ let out = & mut * ( out as * mut & mut String ) ;
438
440
let bytes = slice:: from_raw_parts ( string as * const u8 , len) ;
439
- write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) ;
441
+ write ! ( out, "{}" , String :: from_utf8_lossy( bytes) ) . unwrap ( ) ;
440
442
}
441
443
unsafe {
442
444
llvm:: LLVMRustPrintTargetCPUs (
0 commit comments