1
1
2
2
import driver:: session;
3
+ import session:: session;
3
4
import lib:: llvm:: llvm;
4
5
import front:: attr;
5
6
import middle:: ty;
@@ -30,16 +31,16 @@ tag output_type {
30
31
output_type_exe;
31
32
}
32
33
33
- fn llvm_err ( sess : session:: session , msg : str ) unsafe {
34
+ fn llvm_err ( sess : session , msg : str ) unsafe {
34
35
let buf = llvm:: LLVMRustGetLastError ( ) ;
35
36
if buf == ptr:: null ( ) {
36
37
sess. fatal ( msg) ;
37
38
} else { sess. fatal ( msg + ": " + str:: from_cstr ( buf) ) ; }
38
39
}
39
40
40
- fn load_intrinsics_bc ( sess : session:: session ) -> option:: t < ModuleRef > {
41
+ fn load_intrinsics_bc ( sess : session ) -> option:: t < ModuleRef > {
41
42
let path = alt filesearch:: search (
42
- sess. filesearch ( ) ,
43
+ sess. filesearch ,
43
44
bind filesearch:: pick_file ( "intrinsics.bc" , _) ) {
44
45
option:: some ( path) { path }
45
46
option:: none. {
@@ -64,9 +65,9 @@ fn load_intrinsics_bc(sess: session::session) -> option::t<ModuleRef> {
64
65
ret option:: some ( llintrinsicsmod) ;
65
66
}
66
67
67
- fn load_intrinsics_ll ( sess : session:: session ) -> ModuleRef {
68
+ fn load_intrinsics_ll ( sess : session ) -> ModuleRef {
68
69
let path = alt filesearch:: search (
69
- sess. filesearch ( ) ,
70
+ sess. filesearch ,
70
71
bind filesearch:: pick_file ( "intrinsics.ll" , _) ) {
71
72
option:: some ( path) { path }
72
73
option:: none. { sess . fatal ( "couldn't find intrinsics.ll" ) }
@@ -81,7 +82,7 @@ fn load_intrinsics_ll(sess: session::session) -> ModuleRef {
81
82
ret llintrinsicsmod;
82
83
}
83
84
84
- fn link_intrinsics ( sess : session:: session , llmod : ModuleRef ) {
85
+ fn link_intrinsics ( sess : session , llmod : ModuleRef ) {
85
86
let llintrinsicsmod = {
86
87
alt load_intrinsics_bc ( sess) {
87
88
option:: some ( m) { m }
@@ -122,13 +123,13 @@ mod write {
122
123
} else { stem = str:: substr ( output_path, 0 u, dot_pos as uint ) ; }
123
124
ret stem + "." + extension;
124
125
}
125
- fn run_passes ( sess : session:: session , llmod : ModuleRef , output : str ) {
126
- let opts = sess. get_opts ( ) ;
126
+ fn run_passes ( sess : session , llmod : ModuleRef , output : str ) {
127
+ let opts = sess. opts ;
127
128
if opts. time_llvm_passes { llvm:: LLVMRustEnableTimePasses ( ) ; }
128
129
link_intrinsics ( sess, llmod) ;
129
130
let pm = mk_pass_manager ( ) ;
130
131
let td = mk_target_data (
131
- sess. get_targ_cfg ( ) . target_strs . data_layout ) ;
132
+ sess. targ_cfg . target_strs . data_layout ) ;
132
133
llvm:: LLVMAddTargetData ( td. lltd , pm. llpm ) ;
133
134
// TODO: run the linter here also, once there are llvm-c bindings for
134
135
// it.
@@ -234,7 +235,7 @@ mod write {
234
235
235
236
if opts. output_type == output_type_assembly {
236
237
let _: ( ) = str:: as_buf (
237
- sess. get_targ_cfg ( ) . target_strs . target_triple ,
238
+ sess. targ_cfg . target_strs . target_triple ,
238
239
{ |buf_t|
239
240
str:: as_buf ( output, { |buf_o|
240
241
llvm:: LLVMRustWriteOutputFile (
@@ -254,7 +255,7 @@ mod write {
254
255
opts. output_type == output_type_exe {
255
256
let _: ( ) =
256
257
str:: as_buf (
257
- sess. get_targ_cfg ( ) . target_strs . target_triple ,
258
+ sess. targ_cfg . target_strs . target_triple ,
258
259
{ |buf_t|
259
260
str:: as_buf ( output, { |buf_o|
260
261
llvm:: LLVMRustWriteOutputFile (
@@ -272,7 +273,7 @@ mod write {
272
273
273
274
let _: ( ) =
274
275
str:: as_buf (
275
- sess. get_targ_cfg ( ) . target_strs . target_triple ,
276
+ sess. targ_cfg . target_strs . target_triple ,
276
277
{ |buf_t|
277
278
str:: as_buf ( output, { |buf_o|
278
279
llvm:: LLVMRustWriteOutputFile (
@@ -362,15 +363,15 @@ mod write {
362
363
363
364
type link_meta = { name : str , vers : str , extras_hash : str } ;
364
365
365
- fn build_link_meta ( sess : session:: session , c : ast:: crate , output : str ,
366
+ fn build_link_meta ( sess : session , c : ast:: crate , output : str ,
366
367
sha : sha1 ) -> link_meta {
367
368
368
369
type provided_metas =
369
370
{ name : option:: t < str > ,
370
371
vers : option:: t < str > ,
371
372
cmh_items : [ @ast:: meta_item ] } ;
372
373
373
- fn provided_link_metas ( sess : session:: session , c : ast:: crate ) ->
374
+ fn provided_link_metas ( sess : session , c : ast:: crate ) ->
374
375
provided_metas {
375
376
let name: option:: t < str > = none;
376
377
let vers: option:: t < str > = none;
@@ -430,13 +431,13 @@ fn build_link_meta(sess: session::session, c: ast::crate, output: str,
430
431
ret truncated_sha1_result ( sha) ;
431
432
}
432
433
433
- fn warn_missing ( sess : session:: session , name : str , default : str ) {
434
- if !sess. building_library ( ) { ret; }
434
+ fn warn_missing ( sess : session , name : str , default : str ) {
435
+ if !sess. building_library { ret; }
435
436
sess. warn ( #fmt[ "missing crate link meta '%s', using '%s' as default" ,
436
437
name, default] ) ;
437
438
}
438
439
439
- fn crate_meta_name ( sess : session:: session , _crate : ast:: crate ,
440
+ fn crate_meta_name ( sess : session , _crate : ast:: crate ,
440
441
output : str , metas : provided_metas ) -> str {
441
442
ret alt metas. name {
442
443
some ( v) { v }
@@ -454,7 +455,7 @@ fn build_link_meta(sess: session::session, c: ast::crate, output: str,
454
455
} ;
455
456
}
456
457
457
- fn crate_meta_vers ( sess : session:: session , _crate : ast:: crate ,
458
+ fn crate_meta_vers ( sess : session , _crate : ast:: crate ,
458
459
metas : provided_metas ) -> str {
459
460
ret alt metas. vers {
460
461
some ( v) { v }
@@ -469,7 +470,7 @@ fn build_link_meta(sess: session::session, c: ast::crate, output: str,
469
470
let provided_metas = provided_link_metas ( sess, c) ;
470
471
let name = crate_meta_name ( sess, c, output, provided_metas) ;
471
472
let vers = crate_meta_vers ( sess, c, provided_metas) ;
472
- let dep_hashes = cstore:: get_dep_hashes ( sess. get_cstore ( ) ) ;
473
+ let dep_hashes = cstore:: get_dep_hashes ( sess. cstore ) ;
473
474
let extras_hash =
474
475
crate_meta_extras_hash ( sha, c, provided_metas, dep_hashes) ;
475
476
@@ -557,7 +558,7 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
557
558
558
559
// If the user wants an exe generated we need to invoke
559
560
// gcc to link the object file with some libs
560
- fn link_binary ( sess : session:: session ,
561
+ fn link_binary ( sess : session ,
561
562
obj_filename : str ,
562
563
out_filename : str ,
563
564
lm : link_meta ) {
@@ -586,7 +587,7 @@ fn link_binary(sess: session::session,
586
587
} ;
587
588
}
588
589
589
- let output = if sess. building_library ( ) {
590
+ let output = if sess. building_library {
590
591
let long_libname =
591
592
std:: os:: dylib_filename ( #fmt ( "%s-%s-%s" ,
592
593
lm. name , lm. extras_hash , lm. vers ) ) ;
@@ -602,22 +603,22 @@ fn link_binary(sess: session::session,
602
603
603
604
// The default library location, we need this to find the runtime.
604
605
// The location of crates will be determined as needed.
605
- let stage: str = "-L" + sess. filesearch ( ) . get_target_lib_path ( ) ;
606
+ let stage: str = "-L" + sess. filesearch . get_target_lib_path ( ) ;
606
607
607
608
let prog: str = "gcc" ;
608
609
// The invocations of gcc share some flags across platforms
609
610
610
611
let gcc_args =
611
- [ stage] + sess. get_targ_cfg ( ) . target_strs . gcc_args +
612
+ [ stage] + sess. targ_cfg . target_strs . gcc_args +
612
613
[ "-o" , output, obj_filename] ;
613
614
614
615
let lib_cmd;
615
- let os = sess. get_targ_cfg ( ) . os ;
616
+ let os = sess. targ_cfg . os ;
616
617
if os == session:: os_macos {
617
618
lib_cmd = "-dynamiclib" ;
618
619
} else { lib_cmd = "-shared" ; }
619
620
620
- let cstore = sess. get_cstore ( ) ;
621
+ let cstore = sess. cstore ;
621
622
for cratepath: str in cstore:: get_used_crate_files ( cstore) {
622
623
if str:: ends_with ( cratepath, ".rlib" ) {
623
624
gcc_args += [ cratepath] ;
@@ -626,7 +627,7 @@ fn link_binary(sess: session::session,
626
627
let cratepath = cratepath;
627
628
let dir = fs:: dirname ( cratepath) ;
628
629
if dir != "" { gcc_args += [ "-L" + dir] ; }
629
- let libarg = unlib ( sess. get_targ_cfg ( ) , fs:: basename ( cratepath) ) ;
630
+ let libarg = unlib ( sess. targ_cfg , fs:: basename ( cratepath) ) ;
630
631
gcc_args += [ "-l" + libarg] ;
631
632
}
632
633
@@ -636,12 +637,12 @@ fn link_binary(sess: session::session,
636
637
let used_libs = cstore:: get_used_libraries ( cstore) ;
637
638
for l: str in used_libs { gcc_args += [ "-l" + l] ; }
638
639
639
- if sess. building_library ( ) {
640
+ if sess. building_library {
640
641
gcc_args += [ lib_cmd] ;
641
642
642
643
// On mac we need to tell the linker to let this library
643
644
// be rpathed
644
- if sess. get_targ_cfg ( ) . os == session:: os_macos {
645
+ if sess. targ_cfg . os == session:: os_macos {
645
646
gcc_args += [ "-Wl,-install_name,@rpath/"
646
647
+ fs:: basename ( output) ] ;
647
648
}
@@ -655,11 +656,11 @@ fn link_binary(sess: session::session,
655
656
656
657
// On linux librt and libdl are an indirect dependencies via rustrt,
657
658
// and binutils 2.22+ won't add them automatically
658
- if sess. get_targ_cfg ( ) . os == session:: os_linux {
659
+ if sess. targ_cfg . os == session:: os_linux {
659
660
gcc_args += [ "-lrt" , "-ldl" ] ;
660
661
}
661
662
662
- if sess. get_targ_cfg ( ) . os == session:: os_freebsd {
663
+ if sess. targ_cfg . os == session:: os_freebsd {
663
664
gcc_args += [ "-lrt" , "-L/usr/local/lib" , "-lexecinfo" ,
664
665
"-L/usr/local/lib/gcc46" ,
665
666
"-L/usr/local/lib/gcc44" , "-lstdc++" ,
@@ -672,7 +673,7 @@ fn link_binary(sess: session::session,
672
673
// linker from the dwarf unwind info. Unfortunately, it does not seem to
673
674
// understand how to unwind our __morestack frame, so we have to turn it
674
675
// off. This has impacted some other projects like GHC.
675
- if sess. get_targ_cfg ( ) . os == session:: os_macos {
676
+ if sess. targ_cfg . os == session:: os_macos {
676
677
gcc_args += [ "-Wl,-no_compact_unwind" ] ;
677
678
}
678
679
@@ -692,12 +693,12 @@ fn link_binary(sess: session::session,
692
693
}
693
694
694
695
// Clean up on Darwin
695
- if sess. get_targ_cfg ( ) . os == session:: os_macos {
696
+ if sess. targ_cfg . os == session:: os_macos {
696
697
run:: run_program ( "dsymutil" , [ output] ) ;
697
698
}
698
699
699
700
// Remove the temporary object file if we aren't saving temps
700
- if !sess. get_opts ( ) . save_temps {
701
+ if !sess. opts . save_temps {
701
702
run:: run_program ( "rm" , [ obj_filename] ) ;
702
703
}
703
704
}
0 commit comments