winegcc: Link unix libs directly to native libraries.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-05-28 19:02:56 +02:00 committed by Alexandre Julliard
parent 388c91042c
commit 69ef7374b4
3 changed files with 24 additions and 11 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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@8" : "DriverEntry";
else if (opts->use_msvcrt && !opts->shared && !opts->win16_app)
entry_point = opts->unicode_app ? "wmainCRTStartup" : "mainCRTStartup";