Skip to content

Commit 049072d

Browse files
committed
Update lltrans to also emit WinMain@16 on windows.
1 parent 216082d commit 049072d

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/boot/llvm/llasm.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ let x86_glue
2626
let (prefix,align) =
2727
match sess.Session.sess_targ with
2828
Linux_x86_elf
29-
| Win32_x86_pe -> ("",4)
29+
| Win32_x86_pe -> ("_",4)
3030
| MacOS_x86_macho -> ("_", 16)
3131
in
3232
let save_callee_saves =

src/boot/llvm/llfinal.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*)
55

66
let finalize_module
7+
(sess:Session.sess)
78
(llctx:Llvm.llcontext)
89
(llmod:Llvm.llmodule)
910
(abi:Llabi.abi)
@@ -68,7 +69,13 @@ let finalize_module
6869
(* Define the main function for crt0 to call. *)
6970
let main_fn =
7071
let main_ty = Llvm.function_type i32 [| i32; i32 |] in
71-
Llvm.define_function "main" main_ty llmod
72+
let main_name =
73+
match sess.Session.sess_targ with
74+
Common.Win32_x86_pe -> "WinMain@16"
75+
| Common.Linux_x86_elf
76+
| Common.MacOS_x86_macho -> "main"
77+
in
78+
Llvm.define_function main_name main_ty llmod
7279
in
7380
let argc = Llvm.param main_fn 0 in
7481
let argv = Llvm.param main_fn 1 in

src/boot/llvm/lltrans.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ let trans_crate
11321132
Hashtbl.iter declare_mod_item items;
11331133
Hashtbl.iter trans_mod_item items;
11341134
Llfinal.finalize_module
1135-
llctx llmod abi asm_glue exit_task_glue crate_ptr;
1135+
sess llctx llmod abi asm_glue exit_task_glue crate_ptr;
11361136
llmod
11371137
with e -> Llvm.dispose_module llmod; raise e
11381138
;;

0 commit comments

Comments
 (0)