Update lltrans to also emit WinMain@16 on windows.

This commit is contained in:
Graydon Hoare 2010-11-05 18:45:06 -07:00
parent 216082d040
commit 049072db82
3 changed files with 10 additions and 3 deletions

View file

@ -26,7 +26,7 @@ let x86_glue
let (prefix,align) =
match sess.Session.sess_targ with
Linux_x86_elf
| Win32_x86_pe -> ("",4)
| Win32_x86_pe -> ("_",4)
| MacOS_x86_macho -> ("_", 16)
in
let save_callee_saves =

View file

@ -4,6 +4,7 @@
*)
let finalize_module
(sess:Session.sess)
(llctx:Llvm.llcontext)
(llmod:Llvm.llmodule)
(abi:Llabi.abi)
@ -68,7 +69,13 @@ let finalize_module
(* Define the main function for crt0 to call. *)
let main_fn =
let main_ty = Llvm.function_type i32 [| i32; i32 |] in
Llvm.define_function "main" main_ty llmod
let main_name =
match sess.Session.sess_targ with
Common.Win32_x86_pe -> "WinMain@16"
| Common.Linux_x86_elf
| Common.MacOS_x86_macho -> "main"
in
Llvm.define_function main_name main_ty llmod
in
let argc = Llvm.param main_fn 0 in
let argv = Llvm.param main_fn 1 in

View file

@ -1132,7 +1132,7 @@ let trans_crate
Hashtbl.iter declare_mod_item items;
Hashtbl.iter trans_mod_item items;
Llfinal.finalize_module
llctx llmod abi asm_glue exit_task_glue crate_ptr;
sess llctx llmod abi asm_glue exit_task_glue crate_ptr;
llmod
with e -> Llvm.dispose_module llmod; raise e
;;