Skip to content
This repository

Decides main name by target #5691

Closed
wants to merge 3 commits into from

3 participants

ILYONG CHO bors Daniel Micay
ILYONG CHO
Collaborator

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).

bors bors referenced this pull request from a commit April 03, 2013
bors auto merge of #5691 : ILyoan/rust/main_name, r=graydon
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).
8f20275
ILYONG CHO
Collaborator

Add a commit that fixes a test fail.
r?

Daniel Micay
Collaborator

r+

Collaborator

saw approval from thestinger
at ILyoan@53232f7

Collaborator

merging ILyoan/rust/main_name = 53232f7 into auto

Collaborator

ILyoan/rust/main_name = 53232f7 merged ok, testing candidate = af1baa3

Collaborator

fast-forwarding incoming to auto = af1baa3

bors bors referenced this pull request from a commit April 03, 2013
bors 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).
af1baa3
bors bors closed this April 03, 2013
Jay Anderson jayanderson referenced this pull request from a commit November 10, 2013
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
37  src/librustc/middle/trans/base.rs
@@ -2243,17 +2243,17 @@ pub fn create_main_wrapper(ccx: @CrateContext,
2243 2243
     }
2244 2244
 
2245 2245
     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"; }
2250 2246
         let llfty = T_fn(~[ccx.int_type, T_ptr(T_ptr(T_i8()))], ccx.int_type);
2251 2247
 
2252 2248
         // FIXME #4404 android JNI hacks
2253 2249
         let llfn = if *ccx.sess.building_library {
2254 2250
             decl_cdecl_fn(ccx.llmod, ~"amain", llfty)
2255 2251
         } 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)
2257 2257
         };
2258 2258
         let llbb = str::as_c_str(~"top", |buf| {
2259 2259
             unsafe {
@@ -2284,25 +2284,14 @@ pub fn create_main_wrapper(ccx: @CrateContext,
2284 2284
             let opaque_crate_map = llvm::LLVMBuildPointerCast(
2285 2285
                 bld, crate_map, T_ptr(T_i8()), noname());
2286 2286
 
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
+            ]
2306 2295
         };
2307 2296
 
2308 2297
         unsafe {
2  src/libstd/fileinput.rs
@@ -534,7 +534,7 @@ mod test {
534 534
     fn test_empty_files() {
535 535
         let filenames = pathify(vec::from_fn(
536 536
             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);
538 538
 
539 539
         make_file(filenames[0].get_ref(), ~[~"1", ~"2"]);
540 540
         make_file(filenames[1].get_ref(), ~[]);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.