@@ -15,9 +15,7 @@ use std::io::prelude::*;
1515use std:: io:: { self , BufWriter } ;
1616use std:: path:: { Path , PathBuf } ;
1717
18- use back:: archive;
19- use back:: command:: Command ;
20- use back:: symbol_export;
18+ use command:: Command ;
2119use rustc:: hir:: def_id:: { LOCAL_CRATE , CrateNum } ;
2220use rustc:: middle:: dependency_format:: Linkage ;
2321use rustc:: session:: Session ;
@@ -26,7 +24,6 @@ use rustc::session::config::{self, CrateType, OptLevel, DebugInfo,
2624use rustc:: ty:: TyCtxt ;
2725use rustc_target:: spec:: { LinkerFlavor , LldFlavor } ;
2826use serialize:: { json, Encoder } ;
29- use llvm_util;
3027
3128/// For all the linkers we support, and information they might
3229/// need out of the shared crate context before we get rid of it.
@@ -43,10 +40,13 @@ impl LinkerInfo {
4340 }
4441 }
4542
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 > {
5050 match flavor {
5151 LinkerFlavor :: Lld ( LldFlavor :: Link ) |
5252 LinkerFlavor :: Msvc => {
@@ -70,6 +70,7 @@ impl LinkerInfo {
7070 info : self ,
7171 hinted_static : false ,
7272 is_ld : false ,
73+ target_cpu,
7374 } ) as Box < dyn Linker >
7475 }
7576
@@ -82,6 +83,7 @@ impl LinkerInfo {
8283 info : self ,
8384 hinted_static : false ,
8485 is_ld : true ,
86+ target_cpu,
8587 } ) as Box < dyn Linker >
8688 }
8789
@@ -144,6 +146,7 @@ pub struct GccLinker<'a> {
144146 hinted_static : bool , // Keeps track of the current hinting mode.
145147 // Link as ld
146148 is_ld : bool ,
149+ target_cpu : & ' a str ,
147150}
148151
149152impl < ' a > GccLinker < ' a > {
@@ -204,7 +207,8 @@ impl<'a> GccLinker<'a> {
204207 } ;
205208
206209 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) ) ;
208212
209213 match self . sess . lto ( ) {
210214 config:: Lto :: Thin |
@@ -263,7 +267,7 @@ impl<'a> Linker for GccLinker<'a> {
263267 // -force_load is the macOS equivalent of --whole-archive, but it
264268 // involves passing the full path to the library to link.
265269 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 ) ;
267271 self . linker_arg ( & lib) ;
268272 }
269273 }
@@ -898,7 +902,8 @@ impl<'a> Linker for EmLinker<'a> {
898902fn exported_symbols ( tcx : TyCtxt , crate_type : CrateType ) -> Vec < String > {
899903 let mut symbols = Vec :: new ( ) ;
900904
901- let export_threshold = symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
905+ let export_threshold =
906+ :: symbol_export:: crates_export_threshold ( & [ crate_type] ) ;
902907 for & ( symbol, level) in tcx. exported_symbols ( LOCAL_CRATE ) . iter ( ) {
903908 if level. is_below_threshold ( export_threshold) {
904909 symbols. push ( symbol. symbol_name ( tcx) . to_string ( ) ) ;
0 commit comments