Skip to content

Commit 969e466

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 4325bf1 commit 969e466

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ Version 0.44
3030
as querying the compilers for their library search paths. Support parsing
3131
clang output.
3232
(Antonin Décimo, review by David Allsopp)
33+
- GPR#146: For mingw-w64, select crt2u.o instead of crt2.o if -link -municode
34+
is specified (David Allsopp)
3335

3436
Version 0.43
3537
- 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
@@ -1423,8 +1423,14 @@ let setup_toolchain () =
14231423
with Not_found -> ()
14241424
in
14251425
default_libs := "-lmingw32" :: "-lgcc" :: !default_libs;
1426-
if !exe_mode = `EXE then default_libs := "crt2.o" :: !default_libs
1427-
else default_libs := "dllcrt2.o" :: !default_libs
1426+
if not (List.mem "-nostartfiles" !extra_args) then begin
1427+
if !exe_mode = `EXE then
1428+
if List.mem "-municode" !extra_args then
1429+
default_libs := "crt2u.o" :: !default_libs
1430+
else
1431+
default_libs := "crt2.o" :: !default_libs
1432+
else default_libs := "dllcrt2.o" :: !default_libs
1433+
end
14281434
in
14291435
match !toolchain with
14301436
| _ when !builtin_linker ->

0 commit comments

Comments
 (0)