Alexandre Julliard : makefiles: Don't add a default crt lib for msvcrt dlls.

Alexandre Julliard julliard at winehq.org
Thu Nov 19 16:10:22 CST 2020


Module: wine
Branch: master
Commit: 27b20c1db55f896c2901332ffb5d99f89dcd371c
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=27b20c1db55f896c2901332ffb5d99f89dcd371c

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Nov 19 11:35:22 2020 +0100

makefiles: Don't add a default crt lib for msvcrt dlls.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/makedep.c         | 42 ++++++++++++++++++++++++------------------
 tools/winegcc/winegcc.c |  8 +++++++-
 2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/tools/makedep.c b/tools/makedep.c
index 8812be4e40c..f179f3afa5e 100644
--- a/tools/makedep.c
+++ b/tools/makedep.c
@@ -2276,7 +2276,7 @@ static struct strarray get_default_imports( const struct makefile *make )
 /*******************************************************************
  *         add_crt_import
  */
-static const char *add_crt_import( const struct makefile *make, struct strarray *imports )
+static void add_crt_import( const struct makefile *make, struct strarray *imports, struct strarray *defs )
 {
     unsigned int i;
     const char *crt_dll = NULL;
@@ -2289,10 +2289,28 @@ static const char *add_crt_import( const struct makefile *make, struct strarray
     }
     if (!crt_dll && !strarray_exists( &make->extradllflags, "-nodefaultlibs" ))
     {
-        crt_dll = !make->testdll && !make->staticlib ? "ucrtbase" : "msvcrt";
-        strarray_add( imports, crt_dll );
+        if (make->module &&
+            (!strncmp( make->module, "msvcr", 5 ) ||
+             !strncmp( make->module, "ucrt", 4 ) ||
+             !strcmp( make->module, "crtdll.dll" )))
+        {
+            crt_dll = make->module;
+        }
+        else
+        {
+            crt_dll = !make->testdll && !make->staticlib ? "ucrtbase" : "msvcrt";
+            strarray_add( imports, crt_dll );
+        }
+    }
+
+    if (!defs) return;
+    if (crt_dll && !strncmp( crt_dll, "ucrt", 4 )) strarray_add( defs, "-D_UCRT" );
+    else
+    {
+        unsigned int version = 0;
+        if (crt_dll) sscanf( crt_dll, "msvcr%u", &version );
+        strarray_add( defs, strmake( "-D_MSVCR_VER=%u", version ));
     }
-    return crt_dll;
 }
 
 
@@ -3034,7 +3052,7 @@ static void output_source_spec( struct makefile *make, struct incl_file *source,
     const char *debug_file;
 
     if (!imports.count) imports = make->imports;
-    else if (make->use_msvcrt) add_crt_import( make, &imports );
+    else if (make->use_msvcrt) add_crt_import( make, &imports, NULL );
 
     if (!dll_flags.count) dll_flags = make->extradllflags;
     all_libs = add_import_libs( make, &dep_libs, imports, 0, 0 );
@@ -4200,19 +4218,7 @@ static void load_sources( struct makefile *make )
         make->use_msvcrt = 1;
     }
 
-    if (make->use_msvcrt)
-    {
-        const char *crt_dll = add_crt_import( make, &make->imports );
-
-        if (crt_dll && !strncmp( crt_dll, "ucrt", 4 )) strarray_add( &make->define_args, "-D_UCRT" );
-        else
-        {
-            unsigned int msvcrt_version = 0;
-
-            if (crt_dll) sscanf( crt_dll, "msvcr%u", &msvcrt_version );
-            strarray_add( &make->define_args, strmake( "-D_MSVCR_VER=%u", msvcrt_version ));
-        }
-    }
+    if (make->use_msvcrt) add_crt_import( make, &make->imports, &make->define_args );
 
     LIST_FOR_EACH_ENTRY( file, &make->includes, struct incl_file, entry ) parse_file( make, file, 0 );
     LIST_FOR_EACH_ENTRY( file, &make->sources, struct incl_file, entry ) get_dependencies( file, file );
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index ca45f9bdad0..9268a5dfd1d 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -1224,7 +1224,13 @@ static void build(struct options* opts)
         add_library(opts, lib_dirs, files, "winecrt0");
         if (opts->use_msvcrt)
         {
-            if (!crt_lib) add_library(opts, lib_dirs, files, "ucrtbase");
+            if (!crt_lib)
+            {
+                if (strncmp( output_name, "msvcr", 5 ) &&
+                    strncmp( output_name, "ucrt", 4 ) &&
+                    strcmp( output_name, "crtdll.dll" ))
+                    add_library(opts, lib_dirs, files, "ucrtbase");
+            }
             else strarray_add(files, strmake("-a%s", crt_lib));
         }
         if (opts->win16_app) add_library(opts, lib_dirs, files, "kernel");




More information about the wine-cvs mailing list