1
1
use crate :: back:: write:: {
2
- self , bitcode_section_name, save_temp_bitcode, target_is_aix, target_is_apple,
3
- CodegenDiagnosticsStage , DiagnosticHandlers ,
2
+ self , bitcode_section_name, save_temp_bitcode, CodegenDiagnosticsStage , DiagnosticHandlers ,
4
3
} ;
5
4
use crate :: errors:: {
6
5
DynamicLinkingWithLTO , LlvmError , LtoBitcodeFromRlib , LtoDisallowed , LtoDylib ,
@@ -124,12 +123,9 @@ fn prepare_lto(
124
123
. filter ( |& ( name, _) | looks_like_rust_object_file ( name) ) ;
125
124
for ( name, child) in obj_files {
126
125
info ! ( "adding bitcode from {}" , name) ;
127
- let is_apple = target_is_apple ( cgcx) ;
128
- let is_aix = target_is_aix ( cgcx) ;
129
126
match get_bitcode_slice_from_object_data (
130
127
child. data ( & * archive_data) . expect ( "corrupt rlib" ) ,
131
- is_apple,
132
- is_aix,
128
+ cgcx,
133
129
) {
134
130
Ok ( data) => {
135
131
let module = SerializedModule :: FromRlib ( data. to_vec ( ) ) ;
@@ -151,17 +147,16 @@ fn prepare_lto(
151
147
Ok ( ( symbols_below_threshold, upstream_modules) )
152
148
}
153
149
154
- fn get_bitcode_slice_from_object_data (
155
- obj : & [ u8 ] ,
156
- is_apple : bool ,
157
- is_aix : bool ,
158
- ) -> Result < & [ u8 ] , LtoBitcodeFromRlib > {
150
+ fn get_bitcode_slice_from_object_data < ' a > (
151
+ obj : & ' a [ u8 ] ,
152
+ cgcx : & CodegenContext < LlvmCodegenBackend > ,
153
+ ) -> Result < & ' a [ u8 ] , LtoBitcodeFromRlib > {
159
154
// The object crate doesn't understand bitcode files, but we can just sniff for the possible
160
155
// magic strings here and return the whole slice directly.
161
156
if obj. starts_with ( b"\xDE \xC0 \x17 \x0B " ) || obj. starts_with ( b"BC\xC0 \xDE " ) {
162
157
return Ok ( obj) ;
163
158
}
164
- let section = bitcode_section_name ( is_apple , is_aix ) . trim_end_matches ( '\0' ) ;
159
+ let section = bitcode_section_name ( cgcx ) . trim_end_matches ( '\0' ) ;
165
160
match object:: read:: File :: parse ( obj) {
166
161
Ok ( f) => match f. section_by_name ( section) {
167
162
Some ( d) => Ok ( d. data ( ) . unwrap ( ) ) ,
0 commit comments