For https://gitlab.winehq.org/wine/wine/-/merge_requests/1001.
-- v2: winebuild: Split output_static_lib into output_(import|static)_lib. winebuild: Use asm_name to add underscore prefix in asm_globl. winebuild: Split get_link_name into a separate get_abi_name helper.
From: Rémi Bernon rbernon@codeweavers.com
--- tools/winebuild/utils.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 4f1bdf7cd2d..bac249673b6 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -728,28 +728,28 @@ const char *get_stub_name( const ORDDEF *odp, const DLLSPEC *spec ) }
/* return the stdcall-decorated name for an entry point */ -const char *get_link_name( const ORDDEF *odp ) +static const char *get_abi_name( const ORDDEF *odp, const char *name ) { static char *buffer; char *ret;
- if (target.cpu != CPU_i386) return odp->link_name; + if (target.cpu != CPU_i386) return name;
switch (odp->type) { case TYPE_STDCALL: if (is_pe()) { - if (odp->flags & FLAG_THISCALL) return odp->link_name; - if (odp->flags & FLAG_FASTCALL) ret = strmake( "@%s@%u", odp->link_name, get_args_size( odp )); - else if (!kill_at) ret = strmake( "%s@%u", odp->link_name, get_args_size( odp )); - else return odp->link_name; + if (odp->flags & FLAG_THISCALL) return name; + if (odp->flags & FLAG_FASTCALL) ret = strmake( "@%s@%u", name, get_args_size( odp )); + else if (!kill_at) ret = strmake( "%s@%u", name, get_args_size( odp )); + else return name; } else { - if (odp->flags & FLAG_THISCALL) ret = strmake( "__thiscall_%s", odp->link_name ); - else if (odp->flags & FLAG_FASTCALL) ret = strmake( "__fastcall_%s", odp->link_name ); - else return odp->link_name; + if (odp->flags & FLAG_THISCALL) ret = strmake( "__thiscall_%s", name ); + else if (odp->flags & FLAG_FASTCALL) ret = strmake( "__fastcall_%s", name ); + else return name; } break;
@@ -758,13 +758,13 @@ const char *get_link_name( const ORDDEF *odp ) { int args = get_args_size( odp ); if (odp->flags & FLAG_REGISTER) args += get_ptr_size(); /* context argument */ - ret = strmake( "%s@%u", odp->link_name, args ); + ret = strmake( "%s@%u", name, args ); } - else return odp->link_name; + else return name; break;
default: - return odp->link_name; + return name; }
free( buffer ); @@ -772,6 +772,11 @@ const char *get_link_name( const ORDDEF *odp ) return ret; }
+const char *get_link_name( const ORDDEF *odp ) +{ + return get_abi_name( odp, odp->link_name ); +} + /******************************************************************* * sort_func_list *
From: Rémi Bernon rbernon@codeweavers.com
--- tools/winebuild/utils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index bac249673b6..16d9c28d918 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -1021,8 +1021,7 @@ const char *asm_globl( const char *func ) break; case PLATFORM_MINGW: case PLATFORM_WINDOWS: - buffer = strmake( "\t.globl %s%s\n%s%s:", target.cpu == CPU_i386 ? "_" : "", func, - target.cpu == CPU_i386 ? "_" : "", func ); + buffer = strmake( "\t.globl %s\n%s:", asm_name( func ), asm_name( func ) ); break; default: buffer = strmake( "\t.globl %s\n\t.hidden %s\n%s:", func, func, func );
From: Rémi Bernon rbernon@codeweavers.com
--- tools/winebuild/build.h | 3 ++- tools/winebuild/import.c | 24 ++++++++++-------------- tools/winebuild/main.c | 4 ++-- 3 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 9918c2341f4..7ce502143e3 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -305,7 +305,8 @@ extern void output_module( DLLSPEC *spec ); extern void output_stubs( DLLSPEC *spec ); extern void output_syscalls( DLLSPEC *spec ); extern void output_imports( DLLSPEC *spec ); -extern void output_static_lib( DLLSPEC *spec, struct strarray files ); +extern void output_import_lib( DLLSPEC *spec, struct strarray files ); +extern void output_static_lib( const char *output_name, struct strarray files, int create ); extern void output_exports( DLLSPEC *spec ); extern int load_res32_file( const char *name, DLLSPEC *spec ); extern void output_resources( DLLSPEC *spec ); diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index b1c14db9cab..a2ada71ae36 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -1552,7 +1552,7 @@ static void assemble_files( const char *prefix ) }
/* build a library from the current asm files and any additional object files in argv */ -static void build_library( const char *output_name, struct strarray files, int create ) +void output_static_lib( const char *output_name, struct strarray files, int create ) { struct strarray args;
@@ -1582,7 +1582,7 @@ static void build_library( const char *output_name, struct strarray files, int c }
/* create a Windows-style import library */ -static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec ) +static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec, struct strarray files ) { struct strarray args; char *def_file; @@ -1623,10 +1623,12 @@ static void build_windows_import_lib( const char *lib_name, DLLSPEC *spec ) }
spawn( args ); + + if (files.count) output_static_lib( output_file_name, files, 0 ); }
/* create a Unix-style import library */ -static void build_unix_import_lib( DLLSPEC *spec ) +static void build_unix_import_lib( DLLSPEC *spec, struct strarray files ) { int i, total; const char *name, *prefix; @@ -1679,19 +1681,13 @@ static void build_unix_import_lib( DLLSPEC *spec )
assemble_files( spec->file_name ); free( dll_name ); + + output_static_lib( output_file_name, files, 1 ); }
/* output an import library for a Win32 module and additional object files */ -void output_static_lib( DLLSPEC *spec, struct strarray files ) +void output_import_lib( DLLSPEC *spec, struct strarray files ) { - if (is_pe()) - { - if (spec) build_windows_import_lib( output_file_name, spec ); - if (files.count || !spec) build_library( output_file_name, files, !spec ); - } - else - { - if (spec) build_unix_import_lib( spec ); - build_library( output_file_name, files, 1 ); - } + if (!is_pe()) build_unix_import_lib( spec, files ); + else build_windows_import_lib( output_file_name, spec, files ); } diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index cfccee6cf8b..cbe1e4669c1 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -669,10 +669,10 @@ int main(int argc, char **argv) case MODE_IMPLIB: if (!spec_file_name) fatal_error( "missing .spec file\n" ); if (!parse_input_file( spec )) break; - output_static_lib( spec, files ); + output_import_lib( spec, files ); break; case MODE_STATICLIB: - output_static_lib( NULL, files ); + output_static_lib( output_file_name, files, 1 ); break; case MODE_BUILTIN: if (!files.count) fatal_error( "missing file argument for --builtin option\n" );