@@ -54,7 +54,7 @@ pub enum OutputType {
54
54
OutputTypeExe ,
55
55
}
56
56
57
- pub fn llvm_err ( sess : Session , msg : ~str ) -> ! {
57
+ pub fn llvm_err ( sess : & Session , msg : ~str ) -> ! {
58
58
unsafe {
59
59
let cstr = llvm:: LLVMRustGetLastError ( ) ;
60
60
if cstr == ptr:: null ( ) {
@@ -68,7 +68,7 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! {
68
68
}
69
69
70
70
pub fn WriteOutputFile (
71
- sess : Session ,
71
+ sess : & Session ,
72
72
target : lib:: llvm:: TargetMachineRef ,
73
73
pm : lib:: llvm:: PassManagerRef ,
74
74
m : ModuleRef ,
@@ -125,7 +125,7 @@ pub mod write {
125
125
}
126
126
}
127
127
128
- pub fn run_passes ( sess : Session ,
128
+ pub fn run_passes ( sess : & Session ,
129
129
trans : & CrateTranslation ,
130
130
output_types : & [ OutputType ] ,
131
131
output : & OutputFilenames ) {
@@ -156,7 +156,7 @@ pub mod write {
156
156
157
157
let tm = sess. targ_cfg . target_strs . target_triple . with_c_str ( |t| {
158
158
sess. opts . cg . target_cpu . with_c_str ( |cpu| {
159
- target_feature ( & sess) . with_c_str ( |features| {
159
+ target_feature ( sess) . with_c_str ( |features| {
160
160
llvm:: LLVMRustCreateTargetMachine (
161
161
t, cpu, features,
162
162
lib:: llvm:: CodeModelDefault ,
@@ -323,7 +323,7 @@ pub mod write {
323
323
}
324
324
}
325
325
326
- pub fn run_assembler ( sess : Session , outputs : & OutputFilenames ) {
326
+ pub fn run_assembler ( sess : & Session , outputs : & OutputFilenames ) {
327
327
let cc = super :: get_cc_prog ( sess) ;
328
328
let assembly = outputs. temp_path ( OutputTypeAssembly ) ;
329
329
let object = outputs. path ( OutputTypeObject ) ;
@@ -351,7 +351,7 @@ pub mod write {
351
351
}
352
352
}
353
353
354
- unsafe fn configure_llvm ( sess : Session ) {
354
+ unsafe fn configure_llvm ( sess : & Session ) {
355
355
use sync:: one:: { Once , ONCE_INIT } ;
356
356
static mut INIT : Once = ONCE_INIT ;
357
357
@@ -534,7 +534,7 @@ fn truncated_hash_result(symbol_hasher: &mut Sha256) -> ~str {
534
534
535
535
536
536
// This calculates STH for a symbol, as defined above
537
- fn symbol_hash ( tcx : ty:: ctxt , symbol_hasher : & mut Sha256 ,
537
+ fn symbol_hash ( tcx : & ty:: ctxt , symbol_hasher : & mut Sha256 ,
538
538
t : ty:: t , link_meta : & LinkMeta ) -> ~str {
539
539
// NB: do *not* use abbrevs here as we want the symbol names
540
540
// to be independent of one another in the crate.
@@ -559,7 +559,7 @@ fn get_symbol_hash(ccx: &CrateContext, t: ty::t) -> ~str {
559
559
560
560
let mut type_hashcodes = ccx. type_hashcodes . borrow_mut ( ) ;
561
561
let mut symbol_hasher = ccx. symbol_hasher . borrow_mut ( ) ;
562
- let hash = symbol_hash ( ccx. tcx , symbol_hasher. get ( ) , t, & ccx. link_meta ) ;
562
+ let hash = symbol_hash ( ccx. tcx ( ) , symbol_hasher. get ( ) , t, & ccx. link_meta ) ;
563
563
type_hashcodes. get ( ) . insert ( t, hash. clone ( ) ) ;
564
564
hash
565
565
}
@@ -694,7 +694,7 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems,
694
694
pub fn mangle_internal_name_by_type_only ( ccx : & CrateContext ,
695
695
t : ty:: t ,
696
696
name : & str ) -> ~str {
697
- let s = ppaux:: ty_to_short_str ( ccx. tcx , t) ;
697
+ let s = ppaux:: ty_to_short_str ( ccx. tcx ( ) , t) ;
698
698
let path = [ PathName ( token:: intern ( name) ) ,
699
699
PathName ( token:: intern ( s) ) ] ;
700
700
let hash = get_symbol_hash ( ccx, t) ;
@@ -704,7 +704,7 @@ pub fn mangle_internal_name_by_type_only(ccx: &CrateContext,
704
704
pub fn mangle_internal_name_by_type_and_seq ( ccx : & CrateContext ,
705
705
t : ty:: t ,
706
706
name : & str ) -> ~str {
707
- let s = ppaux:: ty_to_str ( ccx. tcx , t) ;
707
+ let s = ppaux:: ty_to_str ( ccx. tcx ( ) , t) ;
708
708
let path = [ PathName ( token:: intern ( s) ) ,
709
709
gensym_name ( name) ] ;
710
710
let hash = get_symbol_hash ( ccx, t) ;
@@ -719,7 +719,7 @@ pub fn output_lib_filename(id: &CrateId) -> ~str {
719
719
format ! ( "{}-{}-{}" , id. name, crate_id_hash( id) , id. version_or_default( ) )
720
720
}
721
721
722
- pub fn get_cc_prog ( sess : Session ) -> ~str {
722
+ pub fn get_cc_prog ( sess : & Session ) -> ~str {
723
723
match sess. opts . cg . linker {
724
724
Some ( ref linker) => return linker. to_owned ( ) ,
725
725
None => { }
@@ -737,7 +737,7 @@ pub fn get_cc_prog(sess: Session) -> ~str {
737
737
get_system_tool ( sess, "cc" )
738
738
}
739
739
740
- pub fn get_ar_prog ( sess : Session ) -> ~str {
740
+ pub fn get_ar_prog ( sess : & Session ) -> ~str {
741
741
match sess. opts . cg . ar {
742
742
Some ( ref ar) => return ar. to_owned ( ) ,
743
743
None => { }
@@ -746,7 +746,7 @@ pub fn get_ar_prog(sess: Session) -> ~str {
746
746
get_system_tool ( sess, "ar" )
747
747
}
748
748
749
- fn get_system_tool ( sess : Session , tool : & str ) -> ~str {
749
+ fn get_system_tool ( sess : & Session , tool : & str ) -> ~str {
750
750
match sess. targ_cfg . os {
751
751
abi:: OsAndroid => match sess. opts . cg . android_cross_path {
752
752
Some ( ref path) => {
@@ -765,7 +765,7 @@ fn get_system_tool(sess: Session, tool: &str) -> ~str {
765
765
}
766
766
}
767
767
768
- fn remove ( sess : Session , path : & Path ) {
768
+ fn remove ( sess : & Session , path : & Path ) {
769
769
match fs:: unlink ( path) {
770
770
Ok ( ..) => { }
771
771
Err ( e) => {
@@ -776,7 +776,7 @@ fn remove(sess: Session, path: &Path) {
776
776
777
777
/// Perform the linkage portion of the compilation phase. This will generate all
778
778
/// of the requested outputs for this compilation session.
779
- pub fn link_binary ( sess : Session ,
779
+ pub fn link_binary ( sess : & Session ,
780
780
trans : & CrateTranslation ,
781
781
outputs : & OutputFilenames ,
782
782
id : & CrateId ) -> Vec < Path > {
@@ -830,7 +830,7 @@ pub fn filename_for_input(sess: &Session, crate_type: session::CrateType,
830
830
}
831
831
}
832
832
833
- fn link_binary_output ( sess : Session ,
833
+ fn link_binary_output ( sess : & Session ,
834
834
trans : & CrateTranslation ,
835
835
crate_type : session:: CrateType ,
836
836
outputs : & OutputFilenames ,
@@ -840,7 +840,7 @@ fn link_binary_output(sess: Session,
840
840
Some ( ref file) => file. clone ( ) ,
841
841
None => {
842
842
let out_filename = outputs. path ( OutputTypeExe ) ;
843
- filename_for_input ( & sess, crate_type, id, & out_filename)
843
+ filename_for_input ( sess, crate_type, id, & out_filename)
844
844
}
845
845
} ;
846
846
@@ -883,10 +883,10 @@ fn link_binary_output(sess: Session,
883
883
// rlib primarily contains the object file of the crate, but it also contains
884
884
// all of the object files from native libraries. This is done by unzipping
885
885
// native libraries and inserting all of the contents into this archive.
886
- fn link_rlib ( sess : Session ,
887
- trans : Option < & CrateTranslation > , // None == no metadata/bytecode
888
- obj_filename : & Path ,
889
- out_filename : & Path ) -> Archive {
886
+ fn link_rlib < ' a > ( sess : & ' a Session ,
887
+ trans : Option < & CrateTranslation > , // None == no metadata/bytecode
888
+ obj_filename : & Path ,
889
+ out_filename : & Path ) -> Archive < ' a > {
890
890
let mut a = Archive :: create ( sess, out_filename, obj_filename) ;
891
891
892
892
let used_libraries = sess. cstore . get_used_libraries ( ) ;
@@ -985,7 +985,7 @@ fn link_rlib(sess: Session,
985
985
// There's no need to include metadata in a static archive, so ensure to not
986
986
// link in the metadata object file (and also don't prepare the archive with a
987
987
// metadata file).
988
- fn link_staticlib ( sess : Session , obj_filename : & Path , out_filename : & Path ) {
988
+ fn link_staticlib ( sess : & Session , obj_filename : & Path , out_filename : & Path ) {
989
989
let mut a = link_rlib ( sess, None , obj_filename, out_filename) ;
990
990
a. add_native_library ( "morestack" ) . unwrap ( ) ;
991
991
a. add_native_library ( "compiler-rt" ) . unwrap ( ) ;
@@ -1000,7 +1000,7 @@ fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
1000
1000
}
1001
1001
} ;
1002
1002
a. add_rlib ( & p, name, sess. lto ( ) ) . unwrap ( ) ;
1003
- let native_libs = csearch:: get_native_libraries ( sess. cstore , cnum) ;
1003
+ let native_libs = csearch:: get_native_libraries ( & sess. cstore , cnum) ;
1004
1004
for & ( kind, ref lib) in native_libs. iter ( ) {
1005
1005
let name = match kind {
1006
1006
cstore:: NativeStatic => "static library" ,
@@ -1016,7 +1016,7 @@ fn link_staticlib(sess: Session, obj_filename: &Path, out_filename: &Path) {
1016
1016
//
1017
1017
// This will invoke the system linker/cc to create the resulting file. This
1018
1018
// links to all upstream files as well.
1019
- fn link_natively ( sess : Session , dylib : bool , obj_filename : & Path ,
1019
+ fn link_natively ( sess : & Session , dylib : bool , obj_filename : & Path ,
1020
1020
out_filename : & Path ) {
1021
1021
let tmpdir = TempDir :: new ( "rustc" ) . expect ( "needs a temp dir" ) ;
1022
1022
// The invocations of cc share some flags across platforms
@@ -1066,7 +1066,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
1066
1066
}
1067
1067
}
1068
1068
1069
- fn link_args( sess : Session ,
1069
+ fn link_args( sess : & Session ,
1070
1070
dylib : bool ,
1071
1071
tmpdir : & Path ,
1072
1072
obj_filename : & Path ,
@@ -1075,7 +1075,7 @@ fn link_args(sess: Session,
1075
1075
// The default library location, we need this to find the runtime.
1076
1076
// The location of crates will be determined as needed.
1077
1077
// FIXME (#9639): This needs to handle non-utf8 paths
1078
- let lib_path = sess. filesearch . get_target_lib_path ( ) ;
1078
+ let lib_path = sess. filesearch ( ) . get_target_lib_path ( ) ;
1079
1079
let stage: ~str = ~"-L " + lib_path. as_str ( ) . unwrap ( ) ;
1080
1080
1081
1081
let mut args = vec ! ( stage) ;
@@ -1248,7 +1248,7 @@ fn link_args(sess: Session,
1248
1248
// Also note that the native libraries linked here are only the ones located
1249
1249
// in the current crate. Upstream crates with native library dependencies
1250
1250
// may have their native library pulled in above.
1251
- fn add_local_native_libraries ( args : & mut Vec < ~str > , sess : Session ) {
1251
+ fn add_local_native_libraries ( args : & mut Vec < ~str > , sess : & Session ) {
1252
1252
let addl_lib_search_paths = sess. opts . addl_lib_search_paths . borrow ( ) ;
1253
1253
for path in addl_lib_search_paths. get ( ) . iter ( ) {
1254
1254
// FIXME (#9639): This needs to handle non-utf8 paths
@@ -1281,7 +1281,7 @@ fn add_local_native_libraries(args: &mut Vec<~str> , sess: Session) {
1281
1281
// Rust crates are not considered at all when creating an rlib output. All
1282
1282
// dependencies will be linked when producing the final output (instead of
1283
1283
// the intermediate rlib version)
1284
- fn add_upstream_rust_crates ( args : & mut Vec < ~str > , sess : Session ,
1284
+ fn add_upstream_rust_crates ( args : & mut Vec < ~str > , sess : & Session ,
1285
1285
dylib : bool , tmpdir : & Path ) {
1286
1286
1287
1287
// As a limitation of the current implementation, we require that everything
@@ -1302,8 +1302,8 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1302
1302
// * If one form of linking fails, the second is also attempted
1303
1303
// * If both forms fail, then we emit an error message
1304
1304
1305
- let dynamic = get_deps ( sess. cstore , cstore:: RequireDynamic ) ;
1306
- let statik = get_deps ( sess. cstore , cstore:: RequireStatic ) ;
1305
+ let dynamic = get_deps ( & sess. cstore , cstore:: RequireDynamic ) ;
1306
+ let statik = get_deps ( & sess. cstore , cstore:: RequireStatic ) ;
1307
1307
match ( dynamic, statik, sess. opts . cg . prefer_dynamic , dylib) {
1308
1308
( _, Some ( deps) , false , false ) => {
1309
1309
add_static_crates ( args, sess, tmpdir, deps)
@@ -1352,9 +1352,8 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1352
1352
}
1353
1353
1354
1354
// Converts a library file-stem into a cc -l argument
1355
- fn unlib ( config : @session:: Config , stem : & str ) -> ~str {
1356
- if stem. starts_with ( "lib" ) &&
1357
- config. os != abi:: OsWin32 {
1355
+ fn unlib ( config : & session:: Config , stem : & str ) -> ~str {
1356
+ if stem. starts_with ( "lib" ) && config. os != abi:: OsWin32 {
1358
1357
stem. slice ( 3 , stem. len ( ) ) . to_owned ( )
1359
1358
} else {
1360
1359
stem. to_owned ( )
@@ -1376,8 +1375,8 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1376
1375
}
1377
1376
1378
1377
// Adds the static "rlib" versions of all crates to the command line.
1379
- fn add_static_crates ( args : & mut Vec < ~str > , sess : Session , tmpdir : & Path ,
1380
- crates : Vec < ( ast:: CrateNum , Path ) > ) {
1378
+ fn add_static_crates ( args : & mut Vec < ~str > , sess : & Session , tmpdir : & Path ,
1379
+ crates : Vec < ( ast:: CrateNum , Path ) > ) {
1381
1380
for ( cnum, cratepath) in crates. move_iter ( ) {
1382
1381
// When performing LTO on an executable output, all of the
1383
1382
// bytecode from the upstream libraries has already been
@@ -1423,7 +1422,7 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1423
1422
}
1424
1423
1425
1424
// Same thing as above, but for dynamic crates instead of static crates.
1426
- fn add_dynamic_crates ( args : & mut Vec < ~str > , sess : Session ,
1425
+ fn add_dynamic_crates ( args : & mut Vec < ~str > , sess : & Session ,
1427
1426
crates : Vec < ( ast:: CrateNum , Path ) > ) {
1428
1427
// If we're performing LTO, then it should have been previously required
1429
1428
// that all upstream rust dependencies were available in an rlib format.
@@ -1434,7 +1433,7 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1434
1433
// what its name is
1435
1434
let dir = cratepath. dirname_str ( ) . unwrap ( ) ;
1436
1435
if !dir. is_empty ( ) { args. push ( "-L" + dir) ; }
1437
- let libarg = unlib ( sess. targ_cfg , cratepath. filestem_str ( ) . unwrap ( ) ) ;
1436
+ let libarg = unlib ( & sess. targ_cfg , cratepath. filestem_str ( ) . unwrap ( ) ) ;
1438
1437
args. push ( "-l" + libarg) ;
1439
1438
}
1440
1439
}
@@ -1458,8 +1457,8 @@ fn add_upstream_rust_crates(args: &mut Vec<~str> , sess: Session,
1458
1457
// generic function calls a native function, then the generic function must
1459
1458
// be instantiated in the target crate, meaning that the native symbol must
1460
1459
// also be resolved in the target crate.
1461
- fn add_upstream_native_libraries ( args : & mut Vec < ~str > , sess : Session ) {
1462
- let cstore = sess. cstore ;
1460
+ fn add_upstream_native_libraries ( args : & mut Vec < ~str > , sess : & Session ) {
1461
+ let cstore = & sess. cstore ;
1463
1462
cstore. iter_crate_data ( |cnum, _| {
1464
1463
let libs = csearch:: get_native_libraries ( cstore, cnum) ;
1465
1464
for & ( kind, ref lib) in libs. iter ( ) {
0 commit comments