From f06404860ce4c083461483b41879ae40f08a3fc2 Mon Sep 17 00:00:00 2001 From: ILyoan Date: Wed, 3 Apr 2013 14:42:50 +0900 Subject: [PATCH 1/3] Remove a android hack --- src/librustc/middle/trans/base.rs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index aa97c287b4c05..5c5f78aeab6f5 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -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 { From fac0d9d89bd55eccda2549d59b5355afdcaa783f Mon Sep 17 00:00:00 2001 From: ILyoan Date: Wed, 3 Apr 2013 15:44:26 +0900 Subject: [PATCH 2/3] Decides main name by target --- src/librustc/middle/trans/base.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 5c5f78aeab6f5..a8fe60ba68ee8 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -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 { From 53232f7acfa651f14c7ed5afd5ec44da9f82eb08 Mon Sep 17 00:00:00 2001 From: ILyoan Date: Thu, 4 Apr 2013 11:16:26 +0900 Subject: [PATCH 3/3] Fix fileinput test fail --- src/libstd/fileinput.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/fileinput.rs b/src/libstd/fileinput.rs index df733425f3ef0..4ac3e0b174729 100644 --- a/src/libstd/fileinput.rs +++ b/src/libstd/fileinput.rs @@ -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(), ~[]);