Skip to content

Commit

Permalink
remove useless rust_main wrapper
Browse files Browse the repository at this point in the history
the real entry point will now pass the user's main function directly to
the scheduler
  • Loading branch information
thestinger committed Sep 18, 2013
1 parent 4dc3a97 commit c0cc37b
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2388,38 +2388,12 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
let et = ccx.sess.entry_type.unwrap();
match et {
session::EntryMain => {
let llfn = create_main(ccx, main_llfn);
create_entry_fn(ccx, llfn, true);
create_entry_fn(ccx, main_llfn, true);
}
session::EntryStart => create_entry_fn(ccx, main_llfn, false),
session::EntryNone => {} // Do nothing.
}

fn create_main(ccx: @mut CrateContext, main_llfn: ValueRef) -> ValueRef {
let nt = ty::mk_nil();
let llfty = type_of_rust_fn(ccx, [], nt);
let llfdecl = decl_fn(ccx.llmod, "_rust_main",
lib::llvm::CCallConv, llfty);

let fcx = new_fn_ctxt(ccx, ~[], llfdecl, nt, None);

// the args vector built in create_entry_fn will need
// be updated if this assertion starts to fail.
assert!(!fcx.caller_expects_out_pointer);

let bcx = fcx.entry_bcx.unwrap();
// Call main.
let llenvarg = unsafe {
let env_arg = fcx.env_arg_pos();
llvm::LLVMGetParam(llfdecl, env_arg as c_uint)
};
let args = ~[llenvarg];
Call(bcx, main_llfn, args, []);

finish_fn(fcx, bcx);
return llfdecl;
}

fn create_entry_fn(ccx: @mut CrateContext,
rust_main: ValueRef,
use_start_lang_item: bool) {
Expand Down

5 comments on commit c0cc37b

@bors
Copy link
Contributor

@bors bors commented on c0cc37b Sep 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on c0cc37b Sep 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging thestinger/rust/main = c0cc37b into auto

@bors
Copy link
Contributor

@bors bors commented on c0cc37b Sep 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thestinger/rust/main = c0cc37b merged ok, testing candidate = 8f65529

@bors
Copy link
Contributor

@bors bors commented on c0cc37b Sep 18, 2013

@bors
Copy link
Contributor

@bors bors commented on c0cc37b Sep 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 8f65529

Please sign in to comment.