Skip to content

Commit af1baa3

Browse files
committed
auto merge of #5691 : ILyoan/rust/main_name, r=thestinger
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).
2 parents 783392f + 53232f7 commit af1baa3

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/librustc/middle/trans/base.rs

+13-24
Original file line numberDiff line numberDiff line change
@@ -2243,17 +2243,17 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22432243
}
22442244
22452245
fn create_entry_fn(ccx: @CrateContext, rust_main: ValueRef) {
2246-
#[cfg(windows)]
2247-
fn main_name() -> ~str { return ~"WinMain@16"; }
2248-
#[cfg(unix)]
2249-
fn main_name() -> ~str { return ~"main"; }
22502246
let llfty = T_fn(~[ccx.int_type, T_ptr(T_ptr(T_i8()))], ccx.int_type);
22512247
22522248
// FIXME #4404 android JNI hacks
22532249
let llfn = if *ccx.sess.building_library {
22542250
decl_cdecl_fn(ccx.llmod, ~"amain", llfty)
22552251
} else {
2256-
decl_cdecl_fn(ccx.llmod, main_name(), llfty)
2252+
let main_name = match ccx.sess.targ_cfg.os {
2253+
session::os_win32 => ~"WinMain@16",
2254+
_ => ~"main",
2255+
};
2256+
decl_cdecl_fn(ccx.llmod, main_name, llfty)
22572257
};
22582258
let llbb = str::as_c_str(~"top", |buf| {
22592259
unsafe {
@@ -2284,25 +2284,14 @@ pub fn create_main_wrapper(ccx: @CrateContext,
22842284
let opaque_crate_map = llvm::LLVMBuildPointerCast(
22852285
bld, crate_map, T_ptr(T_i8()), noname());
22862286
2287-
if *ccx.sess.building_library {
2288-
~[
2289-
retptr,
2290-
C_null(T_opaque_box_ptr(ccx)),
2291-
opaque_rust_main,
2292-
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
2293-
llvm::LLVMConstInt(T_i32(), 0u as c_ulonglong, False),
2294-
opaque_crate_map
2295-
]
2296-
} else {
2297-
~[
2298-
retptr,
2299-
C_null(T_opaque_box_ptr(ccx)),
2300-
opaque_rust_main,
2301-
llvm::LLVMGetParam(llfn, 0 as c_uint),
2302-
llvm::LLVMGetParam(llfn, 1 as c_uint),
2303-
opaque_crate_map
2304-
]
2305-
}
2287+
~[
2288+
retptr,
2289+
C_null(T_opaque_box_ptr(ccx)),
2290+
opaque_rust_main,
2291+
llvm::LLVMGetParam(llfn, 0 as c_uint),
2292+
llvm::LLVMGetParam(llfn, 1 as c_uint),
2293+
opaque_crate_map
2294+
]
23062295
};
23072296
23082297
unsafe {

src/libstd/fileinput.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ mod test {
534534
fn test_empty_files() {
535535
let filenames = pathify(vec::from_fn(
536536
3,
537-
|i| fmt!("tmp/lib-fileinput-test-next-file-%u.tmp", i)),true);
537+
|i| fmt!("tmp/lib-fileinput-test-empty-files-%u.tmp", i)),true);
538538

539539
make_file(filenames[0].get_ref(), ~[~"1", ~"2"]);
540540
make_file(filenames[1].get_ref(), ~[]);

0 commit comments

Comments
 (0)