1
1
use cranelift_frontend:: { FunctionBuilder , FunctionBuilderContext } ;
2
2
use rustc_hir:: LangItem ;
3
3
use rustc_middle:: ty:: { AssocKind , GenericArg } ;
4
- use rustc_session:: config:: { EntryFnType , sigpipe } ;
4
+ use rustc_session:: config:: EntryFnType ;
5
5
use rustc_span:: DUMMY_SP ;
6
6
use rustc_span:: symbol:: Ident ;
7
7
@@ -15,10 +15,9 @@ pub(crate) fn maybe_create_entry_wrapper(
15
15
is_jit : bool ,
16
16
is_primary_cgu : bool ,
17
17
) {
18
- let ( main_def_id, ( is_main_fn , sigpipe) ) = match tcx. entry_fn ( ( ) ) {
18
+ let ( main_def_id, sigpipe) = match tcx. entry_fn ( ( ) ) {
19
19
Some ( ( def_id, entry_ty) ) => ( def_id, match entry_ty {
20
- EntryFnType :: Main { sigpipe } => ( true , sigpipe) ,
21
- EntryFnType :: Start => ( false , sigpipe:: DEFAULT ) ,
20
+ EntryFnType :: Main { sigpipe } => sigpipe,
22
21
} ) ,
23
22
None => return ,
24
23
} ;
@@ -32,14 +31,13 @@ pub(crate) fn maybe_create_entry_wrapper(
32
31
return ;
33
32
}
34
33
35
- create_entry_fn ( tcx, module, main_def_id, is_jit, is_main_fn , sigpipe) ;
34
+ create_entry_fn ( tcx, module, main_def_id, is_jit, sigpipe) ;
36
35
37
36
fn create_entry_fn (
38
37
tcx : TyCtxt < ' _ > ,
39
38
m : & mut dyn Module ,
40
39
rust_main_def_id : DefId ,
41
40
ignore_lang_start_wrapper : bool ,
42
- is_main_fn : bool ,
43
41
sigpipe : u8 ,
44
42
) {
45
43
let main_ret_ty = tcx. fn_sig ( rust_main_def_id) . no_bound_vars ( ) . unwrap ( ) . output ( ) ;
@@ -95,8 +93,8 @@ pub(crate) fn maybe_create_entry_wrapper(
95
93
96
94
let main_func_ref = m. declare_func_in_func ( main_func_id, & mut bcx. func ) ;
97
95
98
- let result = if is_main_fn && ignore_lang_start_wrapper {
99
- // regular main fn, but ignoring #[lang = "start"] as we are running in the jit
96
+ let result = if ignore_lang_start_wrapper {
97
+ // ignoring #[lang = "start"] as we are running in the jit
100
98
// FIXME set program arguments somehow
101
99
let call_inst = bcx. ins ( ) . call ( main_func_ref, & [ ] ) ;
102
100
let call_results = bcx. func . dfg . inst_results ( call_inst) . to_owned ( ) ;
@@ -134,7 +132,8 @@ pub(crate) fn maybe_create_entry_wrapper(
134
132
types:: I64 => bcx. ins ( ) . sextend ( types:: I64 , res) ,
135
133
_ => unimplemented ! ( "16bit systems are not yet supported" ) ,
136
134
}
137
- } else if is_main_fn {
135
+ } else {
136
+ // Regular main fn invoked via start lang item.
138
137
let start_def_id = tcx. require_lang_item ( LangItem :: Start , None ) ;
139
138
let start_instance = Instance :: expect_resolve (
140
139
tcx,
@@ -151,10 +150,6 @@ pub(crate) fn maybe_create_entry_wrapper(
151
150
let call_inst =
152
151
bcx. ins ( ) . call ( func_ref, & [ main_val, arg_argc, arg_argv, arg_sigpipe] ) ;
153
152
bcx. inst_results ( call_inst) [ 0 ]
154
- } else {
155
- // using user-defined start fn
156
- let call_inst = bcx. ins ( ) . call ( main_func_ref, & [ arg_argc, arg_argv] ) ;
157
- bcx. inst_results ( call_inst) [ 0 ]
158
153
} ;
159
154
160
155
bcx. ins ( ) . return_ ( & [ result] ) ;
0 commit comments