Jacek Caban : winegcc: Link unix libs directly to native libraries.

Alexandre Julliard julliard at winehq.org
Tue Jun 1 16:04:33 CDT 2021


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri May 28 19:02:56 2021 +0200

winegcc: Link unix libs directly to native libraries.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/winegcc/utils.c   | 14 +++++++-------
 tools/winegcc/utils.h   |  2 +-
 tools/winegcc/winegcc.c | 19 ++++++++++++++++---
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c
index 0fe9b04b002..0b82af90683 100644
--- a/tools/winegcc/utils.c
+++ b/tools/winegcc/utils.c
@@ -271,39 +271,39 @@ static char* try_lib_path(const char* dir, const char* pre,
 }
 
 static file_type guess_lib_type(enum target_platform platform, const char* dir,
-                                const char* library, const char *suffix, char** file)
+                                const char* library, const char *prefix, const char *suffix, char** file)
 {
     if (platform != PLATFORM_WINDOWS && platform != PLATFORM_MINGW && platform != PLATFORM_CYGWIN)
     {
         /* Unix shared object */
-        if ((*file = try_lib_path(dir, "lib", library, ".so", file_so)))
+        if ((*file = try_lib_path(dir, prefix, library, ".so", file_so)))
             return file_so;
 
         /* Mach-O (Darwin/Mac OS X) Dynamic Library behaves mostly like .so */
-        if ((*file = try_lib_path(dir, "lib", library, ".dylib", file_so)))
+        if ((*file = try_lib_path(dir, prefix, library, ".dylib", file_so)))
             return file_so;
 
         /* Windows DLL */
-        if ((*file = try_lib_path(dir, "lib", library, ".def", file_def)))
+        if ((*file = try_lib_path(dir, prefix, library, ".def", file_def)))
             return file_dll;
     }
 
     /* static archives */
-    if ((*file = try_lib_path(dir, "lib", library, suffix, file_arh)))
+    if ((*file = try_lib_path(dir, prefix, library, suffix, file_arh)))
 	return file_arh;
 
     return file_na;
 }
 
 file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
-                       const char *suffix, char** file)
+                       const char *prefix, const char *suffix, char** file)
 {
     unsigned int i;
 
     if (!suffix) suffix = ".a";
     for (i = 0; i < path->size; i++)
     {
-        file_type type = guess_lib_type(platform, path->base[i], library, suffix, file);
+        file_type type = guess_lib_type(platform, path->base[i], library, prefix, suffix, file);
 	if (type != file_na) return type;
     }
     return file_na;
diff --git a/tools/winegcc/utils.h b/tools/winegcc/utils.h
index 9c70011a90f..39fe8a8d08a 100644
--- a/tools/winegcc/utils.h
+++ b/tools/winegcc/utils.h
@@ -85,7 +85,7 @@ char* get_basename(const char* file);
 void create_file(const char* name, int mode, const char* fmt, ...);
 file_type get_file_type(const char* filename);
 file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
-                       const char *suffix, char** file);
+                       const char *prefix, const char *suffix, char** file);
 const char *find_binary( const strarray* prefix, const char *name );
 int spawn(const strarray* prefix, const strarray* arr, int ignore_errors);
 
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index e43ad298e60..bcabc4f7998 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -1083,14 +1083,27 @@ static const char *find_libgcc(const strarray *prefix, const strarray *link_tool
 /* add specified library to the list of files */
 static void add_library( struct options *opts, strarray *lib_dirs, strarray *files, const char *library )
 {
-    char *static_lib, *fullname = 0;
+    char *static_lib, *fullname = 0, *unixlib;
 
-    switch(get_lib_type(opts->target_platform, lib_dirs, library, opts->lib_suffix, &fullname))
+    switch(get_lib_type(opts->target_platform, lib_dirs, library, "lib", opts->lib_suffix, &fullname))
     {
     case file_arh:
         strarray_add(files, strmake("-a%s", fullname));
         break;
     case file_dll:
+        if (opts->unix_lib && opts->subsystem && !strcmp(opts->subsystem, "native"))
+        {
+            if (get_lib_type(opts->target_platform, lib_dirs, library, "", ".so", &unixlib) == file_so)
+            {
+                strarray_add(files, strmake("-s%s", unixlib));
+                free(unixlib);
+            }
+            else
+            {
+                strarray_add(files, strmake("-l%s", library));
+            }
+            break;
+        }
         strarray_add(files, strmake("-d%s", fullname));
         if ((static_lib = find_static_lib(fullname)))
         {
@@ -1266,7 +1279,7 @@ static void build(struct options* opts)
     /* set default entry point, if needed */
     if (!opts->entry_point)
     {
-        if (opts->subsystem && !strcmp( opts->subsystem, "native" ))
+        if (opts->subsystem && !opts->unix_lib && !strcmp( opts->subsystem, "native" ))
             entry_point = (is_pe && opts->target_cpu == CPU_x86) ? "DriverEntry at 8" : "DriverEntry";
         else if (opts->use_msvcrt && !opts->shared && !opts->win16_app)
             entry_point = opts->unicode_app ? "wmainCRTStartup" : "mainCRTStartup";




More information about the wine-cvs mailing list