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