11use cranelift_frontend:: { FunctionBuilder , FunctionBuilderContext } ;
22use rustc_hir:: LangItem ;
33use rustc_middle:: ty:: { AssocKind , GenericArg } ;
4- use rustc_session:: config:: { EntryFnType , sigpipe } ;
4+ use rustc_session:: config:: EntryFnType ;
55use rustc_span:: { DUMMY_SP , Ident } ;
66
77use crate :: prelude:: * ;
@@ -14,10 +14,9 @@ pub(crate) fn maybe_create_entry_wrapper(
1414 is_jit : bool ,
1515 is_primary_cgu : bool ,
1616) {
17- let ( main_def_id, ( is_main_fn , sigpipe) ) = match tcx. entry_fn ( ( ) ) {
17+ let ( main_def_id, sigpipe) = match tcx. entry_fn ( ( ) ) {
1818 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,
2120 } ) ,
2221 None => return ,
2322 } ;
@@ -31,14 +30,13 @@ pub(crate) fn maybe_create_entry_wrapper(
3130 return ;
3231 }
3332
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) ;
3534
3635 fn create_entry_fn (
3736 tcx : TyCtxt < ' _ > ,
3837 m : & mut dyn Module ,
3938 rust_main_def_id : DefId ,
4039 ignore_lang_start_wrapper : bool ,
41- is_main_fn : bool ,
4240 sigpipe : u8 ,
4341 ) {
4442 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(
9492
9593 let main_func_ref = m. declare_func_in_func ( main_func_id, & mut bcx. func ) ;
9694
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
9997 // FIXME set program arguments somehow
10098 let call_inst = bcx. ins ( ) . call ( main_func_ref, & [ ] ) ;
10199 let call_results = bcx. func . dfg . inst_results ( call_inst) . to_owned ( ) ;
@@ -133,7 +131,8 @@ pub(crate) fn maybe_create_entry_wrapper(
133131 types:: I64 => bcx. ins ( ) . sextend ( types:: I64 , res) ,
134132 _ => unimplemented ! ( "16bit systems are not yet supported" ) ,
135133 }
136- } else if is_main_fn {
134+ } else {
135+ // Regular main fn invoked via start lang item.
137136 let start_def_id = tcx. require_lang_item ( LangItem :: Start , None ) ;
138137 let start_instance = Instance :: expect_resolve (
139138 tcx,
@@ -150,10 +149,6 @@ pub(crate) fn maybe_create_entry_wrapper(
150149 let call_inst =
151150 bcx. ins ( ) . call ( func_ref, & [ main_val, arg_argc, arg_argv, arg_sigpipe] ) ;
152151 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 ]
157152 } ;
158153
159154 bcx. ins ( ) . return_ ( & [ result] ) ;
0 commit comments