@@ -4,8 +4,7 @@ use std::collections::BTreeMap;
4
4
use std:: fs:: File ;
5
5
use std:: path:: { Path , PathBuf } ;
6
6
7
- use rustc_codegen_ssa:: back:: archive:: { find_library, ArchiveBuilder } ;
8
- use rustc_codegen_ssa:: METADATA_FILENAME ;
7
+ use rustc_codegen_ssa:: back:: archive:: ArchiveBuilder ;
9
8
use rustc_session:: Session ;
10
9
11
10
use object:: { Object , ObjectSymbol , SymbolKind } ;
@@ -19,7 +18,6 @@ enum ArchiveEntry {
19
18
pub ( crate ) struct ArArchiveBuilder < ' a > {
20
19
sess : & ' a Session ,
21
20
dst : PathBuf ,
22
- lib_search_paths : Vec < PathBuf > ,
23
21
use_gnu_style_archive : bool ,
24
22
no_builtin_ranlib : bool ,
25
23
@@ -31,8 +29,6 @@ pub(crate) struct ArArchiveBuilder<'a> {
31
29
32
30
impl < ' a > ArchiveBuilder < ' a > for ArArchiveBuilder < ' a > {
33
31
fn new ( sess : & ' a Session , output : & Path , input : Option < & Path > ) -> Self {
34
- use rustc_codegen_ssa:: back:: link:: archive_search_paths;
35
-
36
32
let ( src_archives, entries) = if let Some ( input) = input {
37
33
let mut archive = ar:: Archive :: new ( File :: open ( input) . unwrap ( ) ) ;
38
34
let mut entries = Vec :: new ( ) ;
@@ -55,7 +51,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
55
51
ArArchiveBuilder {
56
52
sess,
57
53
dst : output. to_path_buf ( ) ,
58
- lib_search_paths : archive_search_paths ( sess) ,
59
54
use_gnu_style_archive : sess. target . archive_format == "gnu" ,
60
55
// FIXME fix builtin ranlib on macOS
61
56
no_builtin_ranlib : sess. target . is_like_osx ,
@@ -85,42 +80,27 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
85
80
) ) ;
86
81
}
87
82
88
- fn add_native_library ( & mut self , name : rustc_span:: symbol:: Symbol , verbatim : bool ) {
89
- let location = find_library ( name, verbatim, & self . lib_search_paths , self . sess ) ;
90
- self . add_archive ( location. clone ( ) , |_| false ) . unwrap_or_else ( |e| {
91
- panic ! ( "failed to add native library {}: {}" , location. to_string_lossy( ) , e) ;
92
- } ) ;
93
- }
94
-
95
- fn add_rlib (
96
- & mut self ,
97
- rlib : & Path ,
98
- name : & str ,
99
- lto : bool ,
100
- skip_objects : bool ,
101
- ) -> std:: io:: Result < ( ) > {
102
- let obj_start = name. to_owned ( ) ;
103
-
104
- self . add_archive ( rlib. to_owned ( ) , move |fname : & str | {
105
- // Ignore metadata files, no matter the name.
106
- if fname == METADATA_FILENAME {
107
- return true ;
108
- }
109
-
110
- // Don't include Rust objects if LTO is enabled
111
- if lto && fname. starts_with ( & obj_start) && fname. ends_with ( ".o" ) {
112
- return true ;
113
- }
83
+ fn add_archive < F > ( & mut self , archive_path : & Path , mut skip : F ) -> std:: io:: Result < ( ) >
84
+ where
85
+ F : FnMut ( & str ) -> bool + ' static ,
86
+ {
87
+ let mut archive = ar:: Archive :: new ( std:: fs:: File :: open ( & archive_path) ?) ;
88
+ let archive_index = self . src_archives . len ( ) ;
114
89
115
- // Otherwise if this is *not* a rust object and we're skipping
116
- // objects then skip this file
117
- if skip_objects && ( !fname. starts_with ( & obj_start) || !fname. ends_with ( ".o" ) ) {
118
- return true ;
90
+ let mut i = 0 ;
91
+ while let Some ( entry) = archive. next_entry ( ) {
92
+ let entry = entry?;
93
+ let file_name = String :: from_utf8 ( entry. header ( ) . identifier ( ) . to_vec ( ) )
94
+ . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , err) ) ?;
95
+ if !skip ( & file_name) {
96
+ self . entries
97
+ . push ( ( file_name, ArchiveEntry :: FromArchive { archive_index, entry_index : i } ) ) ;
119
98
}
99
+ i += 1 ;
100
+ }
120
101
121
- // ok, don't skip this
122
- false
123
- } )
102
+ self . src_archives . push ( ( archive_path. to_owned ( ) , archive) ) ;
103
+ Ok ( ( ) )
124
104
}
125
105
126
106
fn update_symbols ( & mut self ) { }
@@ -264,28 +244,3 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
264
244
bug ! ( "injecting dll imports is not supported" ) ;
265
245
}
266
246
}
267
-
268
- impl < ' a > ArArchiveBuilder < ' a > {
269
- fn add_archive < F > ( & mut self , archive_path : PathBuf , mut skip : F ) -> std:: io:: Result < ( ) >
270
- where
271
- F : FnMut ( & str ) -> bool + ' static ,
272
- {
273
- let mut archive = ar:: Archive :: new ( std:: fs:: File :: open ( & archive_path) ?) ;
274
- let archive_index = self . src_archives . len ( ) ;
275
-
276
- let mut i = 0 ;
277
- while let Some ( entry) = archive. next_entry ( ) {
278
- let entry = entry?;
279
- let file_name = String :: from_utf8 ( entry. header ( ) . identifier ( ) . to_vec ( ) )
280
- . map_err ( |err| std:: io:: Error :: new ( std:: io:: ErrorKind :: InvalidData , err) ) ?;
281
- if !skip ( & file_name) {
282
- self . entries
283
- . push ( ( file_name, ArchiveEntry :: FromArchive { archive_index, entry_index : i } ) ) ;
284
- }
285
- i += 1 ;
286
- }
287
-
288
- self . src_archives . push ( ( archive_path, archive) ) ;
289
- Ok ( ( ) )
290
- }
291
- }
0 commit comments