Skip to content

Commit 5a4298b

Browse files
committed
Don't use process::exit as it is an unreachable on wasm32
1 parent 2cdd1c4 commit 5a4298b

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/librustc_trans/base.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
552552
rust_main: ValueRef,
553553
rust_main_def_id: DefId,
554554
use_start_lang_item: bool) {
555-
// The libstd lang_start function does not return anything, while user defined lang start
556-
// returns a isize
557-
let start_output_ty = if use_start_lang_item { Type::void(ccx) } else { Type::c_int(ccx) };
558-
let llfty = Type::func(&[Type::c_int(ccx), Type::i8p(ccx).ptr_to()], &start_output_ty);
555+
let llfty = Type::func(&[Type::c_int(ccx), Type::i8p(ccx).ptr_to()], &Type::c_int(ccx));
559556

560557
let main_ret_ty = ccx.tcx().fn_sig(rust_main_def_id).output();
561558
// Given that `main()` has no arguments,
@@ -600,12 +597,7 @@ fn maybe_create_entry_wrapper(ccx: &CrateContext) {
600597
};
601598

602599
let result = bld.call(start_fn, &args, None);
603-
604-
if use_start_lang_item {
605-
bld.ret_void();
606-
} else {
607-
bld.ret(bld.intcast(result, Type::c_int(ccx), true));
608-
}
600+
bld.ret(bld.intcast(result, Type::c_int(ccx), true));
609601
}
610602
}
611603

src/libstd/rt.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,18 @@ pub use panicking::{begin_panic, begin_panic_fmt, update_panic_count};
3030
// the real work.
3131
#[cfg(not(any(test, stage0)))]
3232
fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
33-
argc: isize, argv: *const *const u8) -> ! {
33+
argc: isize, argv: *const *const u8) -> isize {
3434
use panic;
3535
use sys;
3636
use sys_common;
3737
use sys_common::thread_info;
3838
use thread::Thread;
39-
use process;
4039
#[cfg(not(feature = "backtrace"))]
4140
use mem;
4241

4342
sys::init();
4443

45-
process::exit(unsafe {
44+
unsafe {
4645
let main_guard = sys::thread::guard::init();
4746
sys::stack_overflow::init();
4847

@@ -65,14 +64,14 @@ fn lang_start_internal(main: &(Fn() -> i32 + Sync + ::panic::RefUnwindSafe),
6564
let exit_code = panic::catch_unwind(move || main());
6665

6766
sys_common::cleanup();
68-
exit_code.unwrap_or(101)
69-
});
67+
exit_code.unwrap_or(101) as isize
68+
}
7069
}
7170

7271
#[cfg(not(any(test, stage0)))]
7372
#[lang = "start"]
7473
fn lang_start<T: ::termination::Termination + 'static>
75-
(main: fn() -> T, argc: isize, argv: *const *const u8) -> !
74+
(main: fn() -> T, argc: isize, argv: *const *const u8) -> isize
7675
{
7776
lang_start_internal(&move || main().report(), argc, argv)
7877
}

0 commit comments

Comments
 (0)