winebuild: Make mingw a separated platform from msvc.

Based on winegcc.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-01-25 15:24:23 +01:00 committed by Alexandre Julliard
parent 6e21a8cc31
commit ea5e89a545
7 changed files with 41 additions and 25 deletions

View File

@ -153,6 +153,7 @@ enum target_platform
PLATFORM_UNSPECIFIED, PLATFORM_UNSPECIFIED,
PLATFORM_APPLE, PLATFORM_APPLE,
PLATFORM_FREEBSD, PLATFORM_FREEBSD,
PLATFORM_MINGW,
PLATFORM_SOLARIS, PLATFORM_SOLARIS,
PLATFORM_WINDOWS PLATFORM_WINDOWS
}; };
@ -161,6 +162,11 @@ extern char *target_alias;
extern enum target_cpu target_cpu; extern enum target_cpu target_cpu;
extern enum target_platform target_platform; extern enum target_platform target_platform;
static inline int is_pe(void)
{
return target_platform == PLATFORM_MINGW || target_platform == PLATFORM_WINDOWS;
}
struct strarray struct strarray
{ {
const char **str; const char **str;

View File

@ -1742,7 +1742,7 @@ void output_syscalls( DLLSPEC *spec )
output( "\t.byte 0xc3\n" ); /* ret */ output( "\t.byte 0xc3\n" ); /* ret */
output( "\tjmp 1f\n" ); output( "\tjmp 1f\n" );
output( "\t.byte 0xc3\n" ); /* ret */ output( "\t.byte 0xc3\n" ); /* ret */
if (target_platform == PLATFORM_WINDOWS) if (is_pe())
{ {
output( "1:\t.byte 0xff,0x14,0x25\n" ); /* 1: callq *(0x7ffe1000) */ output( "1:\t.byte 0xff,0x14,0x25\n" ); /* 1: callq *(0x7ffe1000) */
output( "\t.long 0x7ffe1000\n" ); output( "\t.long 0x7ffe1000\n" );
@ -1803,7 +1803,7 @@ void output_syscalls( DLLSPEC *spec )
/* output the import and delayed import tables of a Win32 module */ /* output the import and delayed import tables of a Win32 module */
void output_imports( DLLSPEC *spec ) void output_imports( DLLSPEC *spec )
{ {
if (target_platform == PLATFORM_WINDOWS) return; if (is_pe()) return;
output_immediate_imports(); output_immediate_imports();
output_delayed_imports( spec ); output_delayed_imports( spec );
output_immediate_import_thunks(); output_immediate_import_thunks();
@ -1958,7 +1958,7 @@ static void build_unix_import_lib( DLLSPEC *spec )
/* output an import library for a Win32 module and additional object files */ /* output an import library for a Win32 module and additional object files */
void output_static_lib( DLLSPEC *spec, char **argv ) void output_static_lib( DLLSPEC *spec, char **argv )
{ {
if (target_platform == PLATFORM_WINDOWS) if (is_pe())
{ {
if (spec) build_windows_import_lib( spec ); if (spec) build_windows_import_lib( spec );
if (argv[0] || !spec) build_library( output_file_name, argv, !spec ); if (argv[0] || !spec) build_library( output_file_name, argv, !spec );

View File

@ -71,7 +71,7 @@ enum target_platform target_platform = PLATFORM_FREEBSD;
#elif defined(__sun) #elif defined(__sun)
enum target_platform target_platform = PLATFORM_SOLARIS; enum target_platform target_platform = PLATFORM_SOLARIS;
#elif defined(_WIN32) #elif defined(_WIN32)
enum target_platform target_platform = PLATFORM_WINDOWS; enum target_platform target_platform = PLATFORM_MINGW;
#else #else
enum target_platform target_platform = PLATFORM_UNSPECIFIED; enum target_platform target_platform = PLATFORM_UNSPECIFIED;
#endif #endif
@ -129,13 +129,14 @@ static const struct
enum target_platform platform; enum target_platform platform;
} platform_names[] = } platform_names[] =
{ {
{ "macos", PLATFORM_APPLE }, { "macos", PLATFORM_APPLE },
{ "darwin", PLATFORM_APPLE }, { "darwin", PLATFORM_APPLE },
{ "freebsd", PLATFORM_FREEBSD }, { "freebsd", PLATFORM_FREEBSD },
{ "solaris", PLATFORM_SOLARIS }, { "solaris", PLATFORM_SOLARIS },
{ "mingw32", PLATFORM_WINDOWS }, { "mingw32", PLATFORM_MINGW },
{ "windows", PLATFORM_WINDOWS }, { "windows-gnu", PLATFORM_MINGW },
{ "winnt", PLATFORM_WINDOWS } { "windows", PLATFORM_WINDOWS },
{ "winnt", PLATFORM_MINGW }
}; };
/* set the dll file name from the input file name */ /* set the dll file name from the input file name */
@ -245,7 +246,7 @@ static void set_target( const char *target )
free( spec ); free( spec );
if (target_cpu == CPU_ARM && target_platform == PLATFORM_WINDOWS) thumb_mode = 1; if (target_cpu == CPU_ARM && is_pe()) thumb_mode = 1;
} }
/* cleanup on program exit */ /* cleanup on program exit */
@ -710,7 +711,7 @@ int main(int argc, char **argv)
else output_fake_module( spec ); else output_fake_module( spec );
break; break;
} }
if (target_platform != PLATFORM_WINDOWS) if (!is_pe())
{ {
load_import_libs( argv ); load_import_libs( argv );
read_undef_symbols( spec, argv ); read_undef_symbols( spec, argv );

View File

@ -379,7 +379,7 @@ static void BuildCallFrom16Core( int reg_func, int thunk )
static void BuildCallTo16Core( int reg_func ) static void BuildCallTo16Core( int reg_func )
{ {
const char *name = reg_func ? "wine_call_to_16_regs" : "wine_call_to_16"; const char *name = reg_func ? "wine_call_to_16_regs" : "wine_call_to_16";
const char *func_name = (target_platform == PLATFORM_WINDOWS ? strmake( "%s@12", name ) : name); const char *func_name = is_pe() ? strmake( "%s@12", name ) : name;
/* Function header */ /* Function header */
function_header( func_name ); function_header( func_name );

View File

@ -499,7 +499,7 @@ void output_resources( DLLSPEC *spec )
dump_res_data( res ); dump_res_data( res );
} }
if (target_platform != PLATFORM_WINDOWS) if (!is_pe())
{ {
output( ".L__wine_spec_resources_end:\n" ); output( ".L__wine_spec_resources_end:\n" );
output( "\t.byte 0\n" ); output( "\t.byte 0\n" );

View File

@ -410,7 +410,7 @@ void output_exports( DLLSPEC *spec )
int needs_imports = 0; int needs_imports = 0;
int needs_relay = has_relays( spec ); int needs_relay = has_relays( spec );
int nr_exports = get_exports_count( spec ); int nr_exports = get_exports_count( spec );
const char *func_ptr = (target_platform == PLATFORM_WINDOWS) ? ".rva" : get_asm_ptr_keyword(); const char *func_ptr = is_pe() ? ".rva" : get_asm_ptr_keyword();
const char *name; const char *name;
if (!nr_exports) return; if (!nr_exports) return;
@ -447,8 +447,7 @@ void output_exports( DLLSPEC *spec )
for (i = spec->base; i <= spec->limit; i++) for (i = spec->base; i <= spec->limit; i++)
{ {
ORDDEF *odp = spec->ordinals[i]; ORDDEF *odp = spec->ordinals[i];
if (!odp) output( "\t%s 0\n", if (!odp) output( "\t%s 0\n", is_pe() ? ".long" : get_asm_ptr_keyword() );
(target_platform == PLATFORM_WINDOWS) ? ".long" : get_asm_ptr_keyword() );
else switch(odp->type) else switch(odp->type)
{ {
case TYPE_EXTERN: case TYPE_EXTERN:
@ -513,7 +512,7 @@ void output_exports( DLLSPEC *spec )
if (needs_relay) if (needs_relay)
{ {
output( "\t.long 0xdeb90002\n" ); /* magic */ output( "\t.long 0xdeb90002\n" ); /* magic */
if (target_platform == PLATFORM_WINDOWS) output_rva( ".L__wine_spec_relay_descr" ); if (is_pe()) output_rva( ".L__wine_spec_relay_descr" );
else output( "\t.long 0\n" ); else output( "\t.long 0\n" );
} }
@ -542,7 +541,7 @@ void output_exports( DLLSPEC *spec )
if (needs_relay) if (needs_relay)
{ {
if (target_platform == PLATFORM_WINDOWS) if (is_pe())
{ {
output( "\t.data\n" ); output( "\t.data\n" );
output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( "\t.align %d\n", get_alignment(get_ptr_size()) );
@ -563,7 +562,7 @@ void output_exports( DLLSPEC *spec )
output_relay_debug( spec ); output_relay_debug( spec );
} }
else if (target_platform != PLATFORM_WINDOWS) else if (!is_pe())
{ {
output( "\t.align %d\n", get_alignment(get_ptr_size()) ); output( "\t.align %d\n", get_alignment(get_ptr_size()) );
output( ".L__wine_spec_exports_end:\n" ); output( ".L__wine_spec_exports_end:\n" );
@ -628,6 +627,7 @@ void output_module( DLLSPEC *spec )
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
return; /* nothing to do */ return; /* nothing to do */
case PLATFORM_APPLE: case PLATFORM_APPLE:
@ -1010,7 +1010,7 @@ void output_def_file( DLLSPEC *spec, int import_only )
if (!is_private) total++; if (!is_private) total++;
if (import_only && odp->type == TYPE_STUB) continue; if (import_only && odp->type == TYPE_STUB) continue;
if ((odp->flags & FLAG_FASTCALL) && target_platform == PLATFORM_WINDOWS) if ((odp->flags & FLAG_FASTCALL) && is_pe())
name = strmake( "@%s", name ); name = strmake( "@%s", name );
output( " %s", name ); output( " %s", name );

View File

@ -462,6 +462,7 @@ struct strarray get_ld_command(void)
case PLATFORM_FREEBSD: case PLATFORM_FREEBSD:
strarray_add( &args, "-m", (force_pointer_size == 8) ? "elf_x86_64_fbsd" : "elf_i386_fbsd", NULL ); strarray_add( &args, "-m", (force_pointer_size == 8) ? "elf_x86_64_fbsd" : "elf_i386_fbsd", NULL );
break; break;
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
strarray_add( &args, "-m", (force_pointer_size == 8) ? "i386pep" : "i386pe", NULL ); strarray_add( &args, "-m", (force_pointer_size == 8) ? "i386pep" : "i386pe", NULL );
break; break;
@ -479,7 +480,7 @@ struct strarray get_ld_command(void)
} }
} }
if (target_cpu == CPU_ARM && target_platform != PLATFORM_WINDOWS) if (target_cpu == CPU_ARM && !is_pe())
strarray_add( &args, "--no-wchar-size-warning", NULL ); strarray_add( &args, "--no-wchar-size-warning", NULL );
return args; return args;
@ -931,7 +932,7 @@ const char *get_link_name( const ORDDEF *odp )
switch (odp->type) switch (odp->type)
{ {
case TYPE_STDCALL: case TYPE_STDCALL:
if (target_platform == PLATFORM_WINDOWS) if (is_pe())
{ {
if (odp->flags & FLAG_THISCALL) return odp->link_name; 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 )); if (odp->flags & FLAG_FASTCALL) ret = strmake( "@%s@%u", odp->link_name, get_args_size( odp ));
@ -947,7 +948,7 @@ const char *get_link_name( const ORDDEF *odp )
break; break;
case TYPE_PASCAL: case TYPE_PASCAL:
if (target_platform == PLATFORM_WINDOWS && !kill_at) if (is_pe() && !kill_at)
{ {
int args = get_args_size( odp ); int args = get_args_size( odp );
if (odp->flags & FLAG_REGISTER) args += get_ptr_size(); /* context argument */ if (odp->flags & FLAG_REGISTER) args += get_ptr_size(); /* context argument */
@ -1099,6 +1100,7 @@ const char *asm_name( const char *sym )
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
if (target_cpu != CPU_x86) return sym; if (target_cpu != CPU_x86) return sym;
if (sym[0] == '@') return sym; /* fastcall */ if (sym[0] == '@') return sym; /* fastcall */
@ -1122,6 +1124,7 @@ const char *func_declaration( const char *func )
{ {
case PLATFORM_APPLE: case PLATFORM_APPLE:
return ""; return "";
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
free( buffer ); free( buffer );
buffer = strmake( ".def %s\n\t.scl 2\n\t.type 32\n\t.endef%s", asm_name(func), buffer = strmake( ".def %s\n\t.scl 2\n\t.type 32\n\t.endef%s", asm_name(func),
@ -1153,6 +1156,7 @@ void output_function_size( const char *name )
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_APPLE: case PLATFORM_APPLE:
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
break; break;
default: default:
@ -1182,6 +1186,7 @@ void output_rva( const char *format, ... )
va_start( valist, format ); va_start( valist, format );
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
output( "\t.rva " ); output( "\t.rva " );
vfprintf( output_file, format, valist ); vfprintf( output_file, format, valist );
@ -1201,6 +1206,7 @@ void output_gnu_stack_note(void)
{ {
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
case PLATFORM_APPLE: case PLATFORM_APPLE:
break; break;
@ -1230,6 +1236,7 @@ const char *asm_globl( const char *func )
case PLATFORM_APPLE: case PLATFORM_APPLE:
buffer = strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func, func, func ); buffer = strmake( "\t.globl _%s\n\t.private_extern _%s\n_%s:", func, func, func );
break; break;
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: case PLATFORM_WINDOWS:
buffer = strmake( "\t.globl %s%s\n%s%s:", target_cpu == CPU_x86 ? "_" : "", func, buffer = strmake( "\t.globl %s%s\n%s%s:", target_cpu == CPU_x86 ? "_" : "", func,
target_cpu == CPU_x86 ? "_" : "", func ); target_cpu == CPU_x86 ? "_" : "", func );
@ -1268,6 +1275,7 @@ const char *get_asm_export_section(void)
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_APPLE: return ".data"; case PLATFORM_APPLE: return ".data";
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: return ".section .edata"; case PLATFORM_WINDOWS: return ".section .edata";
default: return ".section .data"; default: return ".section .data";
} }
@ -1287,6 +1295,7 @@ const char *get_asm_rsrc_section(void)
switch (target_platform) switch (target_platform)
{ {
case PLATFORM_APPLE: return ".data"; case PLATFORM_APPLE: return ".data";
case PLATFORM_MINGW:
case PLATFORM_WINDOWS: return ".section .rsrc"; case PLATFORM_WINDOWS: return ".section .rsrc";
default: return ".section .data"; default: return ".section .data";
} }