From 78ce43f01772bc1ddafdf217cb1390f7e7c8c9d1 Mon Sep 17 00:00:00 2001
From: Jacek Caban <jacek@codeweavers.com>
Date: Mon, 4 May 2020 15:19:43 +0200
Subject: [PATCH] winegcc: Explicitly pass DLL crt entry point to PE linker
 when Wine crt is used.

Linkers don't agree on its default.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
---
 tools/winegcc/winegcc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index a5bc0f45765..95797e6b635 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -1292,6 +1292,9 @@ static void build(struct options* opts)
     for ( j = 0; j < lib_dirs->size; j++ )
 	strarray_add(link_args, strmake("-L%s", lib_dirs->base[j]));
 
+    if (is_pe && opts->use_msvcrt && !entry_point && (opts->shared || opts->win16_app))
+        entry_point = opts->target_cpu == CPU_x86 ? "DllMainCRTStartup@12" : "DllMainCRTStartup";
+
     if (is_pe && entry_point)
         strarray_add(link_args, strmake("-Wl,--entry,%s%s",
                                         is_pe && opts->target_cpu == CPU_x86 ? "_" : "",
-- 
GitLab