Skip to content

Commit

Permalink
auto merge of #5691 : ILyoan/rust/main_name, r=thestinger
Browse files Browse the repository at this point in the history
Existing rust code decides main name by host environment of rustc.
I think it should be chosen by build target.

This patch is also removing one of the android hacks that is not necessary any longer(I think it was not necessary from the first).
  • Loading branch information
bors committed Apr 4, 2013
2 parents 783392f + 53232f7 commit af1baa3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
37 changes: 13 additions & 24 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2243,17 +2243,17 @@ pub fn create_main_wrapper(ccx: @CrateContext,
}

fn create_entry_fn(ccx: @CrateContext, rust_main: ValueRef) {
#[cfg(windows)]
fn main_name() -> ~str { return ~"WinMain@16"; }
#[cfg(unix)]
fn main_name() -> ~str { return ~"main"; }
let llfty = T_fn(~[ccx.int_type, T_ptr(T_ptr(T_i8()))], ccx.int_type);

// FIXME #4404 android JNI hacks
let llfn = if *ccx.sess.building_library {
decl_cdecl_fn(ccx.llmod, ~"amain", llfty)
} else {
decl_cdecl_fn(ccx.llmod, main_name(), llfty)
let main_name = match ccx.sess.targ_cfg.os {
session::os_win32 => ~"WinMain@16",
_ => ~"main",
};
decl_cdecl_fn(ccx.llmod, main_name, llfty)
};
let llbb = str::as_c_str(~"top", |buf| {
unsafe {
Expand Down Expand Up @@ -2284,25 +2284,14 @@ pub fn create_main_wrapper(ccx: @CrateContext,
let opaque_crate_map = llvm::LLVMBuildPointerCast(
bld, crate_map, T_ptr(T_i8()), noname());

if *ccx.sess.building_library {
~[
retptr,
C_null(T_opaque_box_ptr(ccx)),
opaque_rust_main,
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
opaque_crate_map
]
} else {
~[
retptr,
C_null(T_opaque_box_ptr(ccx)),
opaque_rust_main,
llvm::LLVMGetParam(llfn, 0 as c_uint),
llvm::LLVMGetParam(llfn, 1 as c_uint),
opaque_crate_map
]
}
~[
retptr,
C_null(T_opaque_box_ptr(ccx)),
opaque_rust_main,
llvm::LLVMGetParam(llfn, 0 as c_uint),
llvm::LLVMGetParam(llfn, 1 as c_uint),
opaque_crate_map
]
};

unsafe {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/fileinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ mod test {
fn test_empty_files() {
let filenames = pathify(vec::from_fn(
3,
|i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true);
|i| fmt!("tmp/lib-fileinput-test-empty-files-%u.tmp", i)),true);

make_file(filenames[0].get_ref(), ~[~"1", ~"2"]);
make_file(filenames[1].get_ref(), ~[]);
Expand Down

0 comments on commit af1baa3

Please sign in to comment.