From: Jacek Caban <jacek@codeweavers.com> This distinguishes -windows-gnu from -w64-mingw32 based on what Wine tools expect from the compiler. It is now assumed that the underlying toolchain is LLVM and, similarly to the MSVC -windows target, the -target argument is always passed instead of requiring $(CC) to be configured for a specific target. That this does not affect --with-mingw=llvm-mingw builds, which, like other typical mingw distributions, use -w64-mingw32. Those still do not use the -target argument in winebuild and rely on target-specific compiler driver aliases anyway. --- tools/tools.h | 12 ++++++++++-- tools/winebuild/import.c | 4 ++-- tools/winebuild/spec32.c | 1 + tools/winebuild/utils.c | 34 ++++++++++++++++++++++------------ tools/winegcc/winegcc.c | 3 ++- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/tools/tools.h b/tools/tools.h index be569f801d5..5cbe6bc5d42 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -110,6 +110,7 @@ struct target PLATFORM_FREEBSD, PLATFORM_SOLARIS, PLATFORM_WINDOWS, + PLATFORM_WINDOWS_GNU, PLATFORM_MINGW, PLATFORM_CYGWIN } platform; @@ -617,9 +618,16 @@ static inline void set_target_ptr_size( struct target *target, unsigned int size } +static inline bool is_llvm_pe_target( struct target target ) +{ + return target.platform == PLATFORM_WINDOWS || + target.platform == PLATFORM_WINDOWS_GNU; +} + + static inline bool is_pe_target( struct target target ) { - return (target.platform == PLATFORM_WINDOWS || + return (is_llvm_pe_target( target ) || target.platform == PLATFORM_MINGW || target.platform == PLATFORM_CYGWIN); } @@ -668,7 +676,7 @@ static inline int get_platform_from_name( const char *name ) { "freebsd", PLATFORM_FREEBSD }, { "solaris", PLATFORM_SOLARIS }, { "mingw32", PLATFORM_MINGW }, - { "windows-gnu", PLATFORM_MINGW }, + { "windows-gnu", PLATFORM_WINDOWS_GNU }, { "winnt", PLATFORM_MINGW }, { "windows", PLATFORM_WINDOWS }, { "cygwin", PLATFORM_CYGWIN }, diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c index 2d7caa0883e..a2ed34667df 100644 --- a/tools/winebuild/import.c +++ b/tools/winebuild/import.c @@ -1210,7 +1210,7 @@ void output_static_lib( const char *output_name, struct strarray files, int crea { struct strarray args; - if (!create || target.platform != PLATFORM_WINDOWS) + if (!create || !is_llvm_pe_target( target )) { args = find_tool( "ar", NULL ); strarray_add( &args, create ? "rc" : "r" ); @@ -1228,7 +1228,7 @@ void output_static_lib( const char *output_name, struct strarray files, int crea if (create) unlink( output_name ); spawn( args ); - if (target.platform != PLATFORM_WINDOWS) + if (!is_llvm_pe_target( target )) { struct strarray ranlib = find_tool( "ranlib", NULL ); strarray_add( &ranlib, output_name ); diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c index 9d99850f887..11ec69ef446 100644 --- a/tools/winebuild/spec32.c +++ b/tools/winebuild/spec32.c @@ -751,6 +751,7 @@ void output_module( DLLSPEC *spec ) { case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: return; /* nothing to do */ case PLATFORM_APPLE: output( "\t.text\n" ); diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 5492de99c90..d91c2d7a930 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -345,6 +345,7 @@ struct strarray get_ld_command(void) break; case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: strarray_add( &args, "-m" ); strarray_add( &args, (force_pointer_size == 8) ? "i386pep" : "i386pe" ); break; @@ -747,6 +748,7 @@ const char *asm_name( const char *sym ) { case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: if (target.cpu != CPU_i386) return sym; if (sym[0] == '@') return sym; /* fastcall */ /* fall through */ @@ -779,6 +781,7 @@ void output_function_header( const char *func, int global ) break; case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: if (target.cpu == CPU_ARM64EC) output( ".section .text,\"xr\",discard,%s\n\t", name ); output( "\t.def %s\n\t.scl 2\n\t.type 32\n\t.endef\n", name ); if (global) output( "\t.globl %s\n", name ); @@ -800,6 +803,7 @@ void output_function_size( const char *name ) case PLATFORM_APPLE: case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: break; default: output( "\t.size %s, .-%s\n", name, name ); @@ -891,6 +895,7 @@ void output_gnu_stack_note(void) { case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: case PLATFORM_APPLE: break; default: @@ -908,6 +913,7 @@ const char *asm_globl( const char *func ) return strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func, func, func ); case PLATFORM_MINGW: case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: { const char *name = asm_name( func ); return strmake( "\t.globl %s\n%s:", name, name ); @@ -943,10 +949,11 @@ const char *get_asm_export_section(void) { switch (target.platform) { - case PLATFORM_APPLE: return ".data"; + case PLATFORM_APPLE: return ".data"; case PLATFORM_MINGW: - case PLATFORM_WINDOWS: return ".section .edata"; - default: return ".section .data"; + case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: return ".section .edata"; + default: return ".section .data"; } } @@ -954,10 +961,11 @@ const char *get_asm_rodata_section(void) { switch (target.platform) { - case PLATFORM_APPLE: return ".const"; + case PLATFORM_APPLE: return ".const"; case PLATFORM_MINGW: - case PLATFORM_WINDOWS: return ".section .rdata"; - default: return ".section .rodata"; + case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: return ".section .rdata"; + default: return ".section .rodata"; } } @@ -965,10 +973,11 @@ const char *get_asm_rsrc_section(void) { switch (target.platform) { - case PLATFORM_APPLE: return ".data"; + case PLATFORM_APPLE: return ".data"; case PLATFORM_MINGW: - case PLATFORM_WINDOWS: return ".section .rsrc"; - default: return ".section .data"; + case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: return ".section .rsrc"; + default: return ".section .data"; } } @@ -976,9 +985,10 @@ const char *get_asm_string_section(void) { switch (target.platform) { - case PLATFORM_APPLE: return ".cstring"; + case PLATFORM_APPLE: return ".cstring"; case PLATFORM_MINGW: - case PLATFORM_WINDOWS: return ".section .rdata"; - default: return ".section .rodata"; + case PLATFORM_WINDOWS: + case PLATFORM_WINDOWS_GNU: return ".section .rdata"; + default: return ".section .rodata"; } } diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c index 76b9663bffa..6b48a75082a 100644 --- a/tools/winegcc/winegcc.c +++ b/tools/winegcc/winegcc.c @@ -424,7 +424,7 @@ static struct strarray build_tool_name( const char *target_name, struct tool_nam if (cc_cmd && !strncmp( tool.llvm_base, "clang", 5 )) { ret = strarray_fromstring( cc_cmd, " " ); - if (target.platform == PLATFORM_WINDOWS) add_clang_options( target_name, &ret ); + if (is_llvm_pe_target( target )) add_clang_options( target_name, &ret ); return ret; } @@ -543,6 +543,7 @@ static struct strarray get_link_args( const char *output_name ) case PLATFORM_MINGW: case PLATFORM_CYGWIN: + case PLATFORM_WINDOWS_GNU: strarray_add( &link_args, "-nodefaultlibs" ); strarray_add( &link_args, "-nostartfiles" ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10273