From 07f77c41488c5626c56b6c06babb18303a910658 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 15 Jan 2009 21:17:51 +0100 Subject: [PATCH] winebuild: Add -m32/-m64 options to allow 32/64-bit cross-compiles. --- configure | 7 ++++++- configure.ac | 3 +++ tools/winebuild/build.h | 1 + tools/winebuild/main.c | 22 ++++++++++++++++++++++ tools/winebuild/winebuild.man.in | 3 +++ 5 files changed, 35 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 6e721f782bb..3f0e4bde03d 100755 --- a/configure +++ b/configure @@ -745,10 +745,10 @@ X_PRE_LIBS X_CFLAGS CPP XMKMF -TARGETFLAGS TOOLSDIR WIN16_INSTALL WIN16_FILES +TARGETFLAGS CPPBIN ac_ct_CXX CXXFLAGS @@ -3867,6 +3867,11 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ AS="${AS:-as} --32" host_cpu="i386" notice_platform="32-bit " + TARGETFLAGS="-m32" + + else + TARGETFLAGS="-m64" + fi ;; esac diff --git a/configure.ac b/configure.ac index 63ac5aa6b7e..72f93b7dcb3 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,9 @@ case $host in AS="${AS:-as} --32" host_cpu="i386" notice_platform="32-bit " + AC_SUBST(TARGETFLAGS,"-m32") + else + AC_SUBST(TARGETFLAGS,"-m64") fi ;; esac diff --git a/tools/winebuild/build.h b/tools/winebuild/build.h index 45c75f7df05..0ee7bde0836 100644 --- a/tools/winebuild/build.h +++ b/tools/winebuild/build.h @@ -231,6 +231,7 @@ extern int kill_at; extern int verbose; extern int save_temps; extern int link_ext_symbols; +extern int force_pointer_size; extern char *input_file_name; extern char *spec_file_name; diff --git a/tools/winebuild/main.c b/tools/winebuild/main.c index e88522fc833..126b9992323 100644 --- a/tools/winebuild/main.c +++ b/tools/winebuild/main.c @@ -48,6 +48,7 @@ int kill_at = 0; int verbose = 0; int save_temps = 0; int link_ext_symbols = 0; +int force_pointer_size = 0; #ifdef __i386__ enum target_cpu target_cpu = CPU_x86; @@ -240,6 +241,7 @@ static const char usage_str[] = " --ld-cmd=LD Command to use for linking (default: ld)\n" " -l, --library=LIB Import the specified library\n" " -L, --library-path=DIR Look for imports libraries in DIR\n" +" -m32, -m64 Force building 32-bit resp. 64-bit code\n" " -M, --main-module=MODULE Set the name of the main module for a Win16 dll\n" " --nm-cmd=NM Command to use to get undefined symbols (default: nm)\n" " --nxcompat=y|n Set the NX compatibility flag (default: yes)\n" @@ -365,6 +367,12 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) lib_path = xrealloc( lib_path, (nb_lib_paths+1) * sizeof(*lib_path) ); lib_path[nb_lib_paths++] = xstrdup( optarg ); break; + case 'm': + if (strcmp( optarg, "32" ) && strcmp( optarg, "64" )) + fatal_error( "Invalid -m option '%s', expected -m32 or -m64\n", optarg ); + if (!strcmp( optarg, "32" )) force_pointer_size = 4; + else force_pointer_size = 8; + break; case 'M': spec->type = SPEC_WIN16; break; @@ -490,6 +498,20 @@ static char **parse_options( int argc, char **argv, DLLSPEC *spec ) if (spec->file_name && !strchr( spec->file_name, '.' )) strcat( spec->file_name, exec_mode == MODE_EXE ? ".exe" : ".dll" ); + switch (target_cpu) + { + case CPU_x86: + if (force_pointer_size == 8) target_cpu = CPU_x86_64; + break; + case CPU_x86_64: + if (force_pointer_size == 4) target_cpu = CPU_x86; + break; + default: + if (force_pointer_size == 8) + fatal_error( "Cannot build 64-bit code for this CPU\n" ); + break; + } + return &argv[optind]; } diff --git a/tools/winebuild/winebuild.man.in b/tools/winebuild/winebuild.man.in index 08e8d1bc60f..d8bc569e267 100644 --- a/tools/winebuild/winebuild.man.in +++ b/tools/winebuild/winebuild.man.in @@ -143,6 +143,9 @@ Import the specified library, looking for a corresponding \fIlibname.def\fR file in the directories specified with the \fB-L\fR option. .TP +.B \-m32, -m64 +Generate 32-bit, respectively 64-bit code. +.TP .BI \-M,\ --main-module= module Specify that we are building a 16-bit dll, that will ultimately be linked together with the 32-bit dll specified in \fImodule\fR. Only