Skip to content

Commit 39c90a2

Browse files
committed
Choose the correct startup object for mingw-w64
If -municode is passed to mingw-w64's gcc, then crt2u.o (which causes wmain to be selected) should be linked rather than crt2.o. In passing, the code now sniffs for -nostartfiles, which causes neither crt2.o nor crt2u.o to be considered.
1 parent 338ff13 commit 39c90a2

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGES

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
Next version
22
- GPR#127: Recognise hyphens in option names in the COFF .drectve section. Fixes #126 (Reza Barazesh)
33
- GPR#136: Fix parallel access crashes and misbehavior (David Allsopp, Jan Midtgaard, Antonin Décimo)
4-
4+
- GPR#146: For mingw-w64, select crt2u.o instead of crt2.o if -link -municode
5+
is specified (David Allsopp)
56

67
Version 0.43
78
- GPR#108: Add -lgcc_s to Cygwin's link libraries, upstreaming a patch from the

reloc.ml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,8 +1378,14 @@ let setup_toolchain () =
13781378
default_libs :=
13791379
["-lmingw32"; "-lgcc"; "-lgcc_eh"; "-lmoldname"; "-lmingwex"; "-lmsvcrt";
13801380
"-luser32"; "-lkernel32"; "-ladvapi32"; "-lshell32" ];
1381-
if !exe_mode = `EXE then default_libs := "crt2.o" :: !default_libs
1382-
else default_libs := "dllcrt2.o" :: !default_libs
1381+
if not (List.mem "-nostartfiles" !extra_args) then begin
1382+
if !exe_mode = `EXE then
1383+
if List.mem "-municode" !extra_args then
1384+
default_libs := "crt2u.o" :: !default_libs
1385+
else
1386+
default_libs := "crt2.o" :: !default_libs
1387+
else default_libs := "dllcrt2.o" :: !default_libs
1388+
end
13831389
in
13841390
match !toolchain with
13851391
| _ when !builtin_linker ->

0 commit comments

Comments
 (0)