@@ -29,7 +29,7 @@ use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
29
29
use rustc_codegen_ssa:: traits:: * ;
30
30
use rustc_codegen_ssa:: { ModuleCodegen , ModuleKind , looks_like_rust_object_file} ;
31
31
use rustc_data_structures:: memmap:: Mmap ;
32
- use rustc_errors:: { DiagCtxtHandle , FatalError } ;
32
+ use rustc_errors:: DiagCtxtHandle ;
33
33
use rustc_middle:: bug;
34
34
use rustc_middle:: dep_graph:: WorkProduct ;
35
35
use rustc_session:: config:: Lto ;
@@ -51,12 +51,11 @@ fn prepare_lto(
51
51
cgcx : & CodegenContext < GccCodegenBackend > ,
52
52
each_linked_rlib_for_lto : & [ PathBuf ] ,
53
53
dcx : DiagCtxtHandle < ' _ > ,
54
- ) -> Result < LtoData , FatalError > {
54
+ ) -> LtoData {
55
55
let tmp_path = match tempdir ( ) {
56
56
Ok ( tmp_path) => tmp_path,
57
57
Err ( error) => {
58
- eprintln ! ( "Cannot create temporary directory: {}" , error) ;
59
- return Err ( FatalError ) ;
58
+ dcx. fatal ( format ! ( "Cannot create temporary directory: {}" , error) ) ;
60
59
}
61
60
} ;
62
61
@@ -91,15 +90,14 @@ fn prepare_lto(
91
90
upstream_modules. push ( ( module, CString :: new ( name) . unwrap ( ) ) ) ;
92
91
}
93
92
Err ( e) => {
94
- dcx. emit_err ( e) ;
95
- return Err ( FatalError ) ;
93
+ dcx. emit_fatal ( e) ;
96
94
}
97
95
}
98
96
}
99
97
}
100
98
}
101
99
102
- Ok ( LtoData { upstream_modules, tmp_path } )
100
+ LtoData { upstream_modules, tmp_path }
103
101
}
104
102
105
103
fn save_as_file ( obj : & [ u8 ] , path : & Path ) -> Result < ( ) , LtoBitcodeFromRlib > {
@@ -114,10 +112,10 @@ pub(crate) fn run_fat(
114
112
cgcx : & CodegenContext < GccCodegenBackend > ,
115
113
each_linked_rlib_for_lto : & [ PathBuf ] ,
116
114
modules : Vec < FatLtoInput < GccCodegenBackend > > ,
117
- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
115
+ ) -> ModuleCodegen < GccContext > {
118
116
let dcx = cgcx. create_dcx ( ) ;
119
117
let dcx = dcx. handle ( ) ;
120
- let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ? ;
118
+ let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
121
119
/*let symbols_below_threshold =
122
120
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
123
121
fat_lto (
@@ -137,7 +135,7 @@ fn fat_lto(
137
135
mut serialized_modules : Vec < ( SerializedModule < ModuleBuffer > , CString ) > ,
138
136
tmp_path : TempDir ,
139
137
//symbols_below_threshold: &[String],
140
- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
138
+ ) -> ModuleCodegen < GccContext > {
141
139
let _timer = cgcx. prof . generic_activity ( "GCC_fat_lto_build_monolithic_module" ) ;
142
140
info ! ( "going for a fat lto" ) ;
143
141
@@ -261,7 +259,7 @@ fn fat_lto(
261
259
// of now.
262
260
module. module_llvm . temp_dir = Some ( tmp_path) ;
263
261
264
- Ok ( module)
262
+ module
265
263
}
266
264
267
265
pub struct ModuleBuffer ( PathBuf ) ;
@@ -286,10 +284,10 @@ pub(crate) fn run_thin(
286
284
each_linked_rlib_for_lto : & [ PathBuf ] ,
287
285
modules : Vec < ( String , ThinBuffer ) > ,
288
286
cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
289
- ) -> Result < ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
287
+ ) -> ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) {
290
288
let dcx = cgcx. create_dcx ( ) ;
291
289
let dcx = dcx. handle ( ) ;
292
- let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ? ;
290
+ let lto_data = prepare_lto ( cgcx, each_linked_rlib_for_lto, dcx) ;
293
291
if cgcx. opts . cg . linker_plugin_lto . enabled ( ) {
294
292
unreachable ! (
295
293
"We should never reach this case if the LTO step \
@@ -355,7 +353,7 @@ fn thin_lto(
355
353
tmp_path : TempDir ,
356
354
cached_modules : Vec < ( SerializedModule < ModuleBuffer > , WorkProduct ) > ,
357
355
//_symbols_below_threshold: &[String],
358
- ) -> Result < ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) , FatalError > {
356
+ ) -> ( Vec < ThinModule < GccCodegenBackend > > , Vec < WorkProduct > ) {
359
357
let _timer = cgcx. prof . generic_activity ( "LLVM_thin_lto_global_analysis" ) ;
360
358
info ! ( "going for that thin, thin LTO" ) ;
361
359
@@ -518,13 +516,13 @@ fn thin_lto(
518
516
// TODO: save the directory so that it gets deleted later.
519
517
std:: mem:: forget ( tmp_path) ;
520
518
521
- Ok ( ( opt_jobs, copy_jobs) )
519
+ ( opt_jobs, copy_jobs)
522
520
}
523
521
524
522
pub fn optimize_thin_module (
525
523
thin_module : ThinModule < GccCodegenBackend > ,
526
524
_cgcx : & CodegenContext < GccCodegenBackend > ,
527
- ) -> Result < ModuleCodegen < GccContext > , FatalError > {
525
+ ) -> ModuleCodegen < GccContext > {
528
526
//let dcx = cgcx.create_dcx();
529
527
530
528
//let module_name = &thin_module.shared.module_names[thin_module.idx];
@@ -634,7 +632,8 @@ pub fn optimize_thin_module(
634
632
save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
635
633
}
636
634
}*/
637
- Ok ( module)
635
+ #[ allow( clippy:: let_and_return) ]
636
+ module
638
637
}
639
638
640
639
pub struct ThinBuffer {
0 commit comments