@@ -15,9 +15,7 @@ use std::io::prelude::*;
15
15
use std:: io:: { self , BufWriter } ;
16
16
use std:: path:: { Path , PathBuf } ;
17
17
18
- use back:: archive;
19
- use back:: command:: Command ;
20
- use back:: symbol_export;
18
+ use command:: Command ;
21
19
use rustc:: hir:: def_id:: { LOCAL_CRATE , CrateNum } ;
22
20
use rustc:: middle:: dependency_format:: Linkage ;
23
21
use rustc:: session:: Session ;
@@ -26,7 +24,6 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
26
24
use rustc:: ty:: TyCtxt ;
27
25
use rustc_target:: spec:: { LinkerFlavor , LldFlavor } ;
28
26
use serialize:: { json, Encoder } ;
29
- use llvm_util;
30
27
31
28
/// For all the linkers we support, and information they might
32
29
/// need out of the shared crate context before we get rid of it.
@@ -43,10 +40,13 @@ impl LinkerInfo {
43
40
}
44
41
}
45
42
46
- pub fn to_linker < ' a > ( & ' a self ,
47
- cmd : Command ,
48
- sess : & ' a Session ,
49
- flavor : LinkerFlavor ) -> Box < dyn Linker +' a > {
43
+ pub fn to_linker < ' a > (
44
+ & ' a self ,
45
+ cmd : Command ,
46
+ sess : & ' a Session ,
47
+ flavor : LinkerFlavor ,
48
+ target_cpu : & ' a str ,
49
+ ) -> Box < dyn Linker +' a > {
50
50
match flavor {
51
51
LinkerFlavor :: Lld ( LldFlavor :: Link ) |
52
52
LinkerFlavor :: Msvc => {
@@ -70,6 +70,7 @@ impl LinkerInfo {
70
70
info : self ,
71
71
hinted_static : false ,
72
72
is_ld : false ,
73
+ target_cpu,
73
74
} ) as Box < dyn Linker >
74
75
}
75
76
@@ -82,6 +83,7 @@ impl LinkerInfo {
82
83
info : self ,
83
84
hinted_static : false ,
84
85
is_ld : true ,
86
+ target_cpu,
85
87
} ) as Box < dyn Linker >
86
88
}
87
89
@@ -144,6 +146,7 @@ pub struct GccLinker<'a> {
144
146
hinted_static : bool , // Keeps track of the current hinting mode.
145
147
// Link as ld
146
148
is_ld : bool ,
149
+ target_cpu : & ' a str ,
147
150
}
148
151
149
152
impl < ' a > GccLinker < ' a > {
@@ -204,7 +207,8 @@ impl<'a> GccLinker<'a> {
204
207
} ;
205
208
206
209
self . linker_arg ( & format ! ( "-plugin-opt={}" , opt_level) ) ;
207
- self . linker_arg ( & format ! ( "-plugin-opt=mcpu={}" , llvm_util:: target_cpu( self . sess) ) ) ;
210
+ let target_cpu = self . target_cpu ;
211
+ self . linker_arg ( & format ! ( "-plugin-opt=mcpu={}" , target_cpu) ) ;
208
212
209
213
match self . sess . lto ( ) {
210
214
config:: Lto :: Thin |
@@ -263,7 +267,7 @@ impl<'a> Linker for GccLinker<'a> {
263
267
// -force_load is the macOS equivalent of --whole-archive, but it
264
268
// involves passing the full path to the library to link.
265
269
self . linker_arg ( "-force_load" ) ;
266
- let lib = archive :: find_library ( lib, search_path, & self . sess ) ;
270
+ let lib = :: find_library ( lib, search_path, & self . sess ) ;
267
271
self . linker_arg ( & lib) ;
268
272
}
269
273
}
@@ -898,7 +902,8 @@ impl<'a> Linker for EmLinker<'a> {
898
902
fn exported_symbols ( tcx : TyCtxt , crate_type : CrateType ) -> Vec < String > {
899
903
let mut symbols = Vec :: new ( ) ;
900
904
901
- let export_threshold = symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
905
+ let export_threshold =
906
+ :: symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
902
907
for & ( symbol, level) in tcx. exported_symbols ( LOCAL_CRATE ) . iter ( ) {
903
908
if level. is_below_threshold ( export_threshold) {
904
909
symbols. push ( symbol. symbol_name ( tcx) . to_string ( ) ) ;
0 commit comments