configure: Check the type of binaries produced by the compiler rather than that used by the host environment.

Francois Gouget fgouget at
Mon Aug 31 04:47:30 CDT 2009

This better deals with 32bit chroots on 64bit x86 systems.

To run gcc 2.95 I use a chroot environment since it is no longer 
supported in the current Debian releases. This is a 32bit Debian 4.0 
chroot so it naturally produces 32bit binaries.

However configure's $host variable still gets set to x86_64-*, 
presumably because uname still reports the machine as being 64bit since 
it's running a 64bit kernel.

This causes Wine's to unconditionally add the 
unneeded '-m32' option to the gcc command line. However gcc 2.95 does 
not support that option so I get an error telling me the compiler cannot 
produce binaries.

I think the core of the problem is that we should check the kind of 
binaries produced by the compiler rather than the host architecture to 
determine whether to add -m32 or not.

So this is what this patch does by calling 'gcc -dumpmachine'. But maybe 
there's a better way... |   29 +++++++++++++++++++----------
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/ b/
index 1925035..3c8e402 100644
--- a/
+++ b/
@@ -107,7 +107,16 @@ dnl We can't use AC_PROG_CPP for winegcc, it uses by default $(CC) -E
 AC_DEFINE_UNQUOTED(EXEEXT,["$ac_exeext"],[Define to the file extension for executables.])
-case $host in
+cc_host=`$CC -dumpmachine 2>/dev/null`
+if test "x$cc_host" = "x"
+    cc_host="$host"
+    cc_cpu="$host_cpu"
+    cc_cpu=`echo "$cc_host" | sed -e 's/-.*//'`
+case $cc_host in
     if test "x$enable_win64" = "xyes"
@@ -115,7 +124,7 @@ case $host in
       CXX="$CXX -m64"
       LD="${LD:-ld} -arch x86_64"
       AS="${AS:-as} -arch x86_64"
-      host_cpu="x86_64"
+      cc_cpu="x86_64"
       notice_platform="64-bit "
@@ -123,7 +132,7 @@ case $host in
       CXX="$CXX -m32"
       LD="${LD:-ld} -arch i386"
       AS="${AS:-as} -arch i386"
-      host_cpu="i386"
+      cc_cpu="i386"
       notice_platform="32-bit "
@@ -140,7 +149,7 @@ case $host in
                       AC_MSG_ERROR([Cannot build a 32-bit program, you need to install 32-bit development libraries.])])
       LD="${LD:-ld} -m elf_i386"
       AS="${AS:-as} --32"
-      host_cpu="i386"
+      cc_cpu="i386"
       notice_platform="32-bit "
@@ -273,7 +282,7 @@ then
   if test "$ICOTOOL" = "false"; then WINE_WARNING([icotool is missing, icons can't be rebuilt.]); fi
-case $host_cpu in
+case $cc_cpu in
     AC_PATH_PROG(PRELINK, prelink, false, [/sbin /usr/sbin $PATH])
@@ -632,7 +641,7 @@ case $host_os in
-    case $host_cpu in
+    case $cc_cpu in
         LDDLLFLAGS="$LDDLLFLAGS -read_only_relocs warning"  dnl FIXME
@@ -699,7 +708,7 @@ case $host_os in
                       [LDRPATH_INSTALL="$LDRPATH_INSTALL -Wl,--enable-new-dtags"])
-      case $host_cpu in
+      case $cc_cpu in
         *i[[3456789]]86* | x86_64)
                           [LDEXECFLAGS="$LDEXECFLAGS -Wl,--section-start,.interp=0x7bf00400"])
@@ -1488,7 +1497,7 @@ AC_CACHE_CHECK([whether external symbols need an underscore prefix], ac_cv_c_ext
                       [if (ac_test) return 1],
-case $host_cpu in
+case $cc_cpu in
     AC_CACHE_CHECK([whether external symbols need stdcall decoration], ac_cv_c_stdcall_suffix,
         WINE_TRY_ASM_LINK(["jmp _ac_test at 4"],
@@ -1613,7 +1622,7 @@ esac
 test -z "$with_wine64" || MAIN_BINARY="wine32"
-case $host_cpu in
+case $cc_cpu in
     case $host_os in
       linux* | k*bsd*-gnu)
@@ -2011,7 +2020,7 @@ fi
 dnl *** check for the need to define platform-specific symbols
-case $host_cpu in
+case $cc_cpu in
   *i[[3456789]]86*) WINE_CHECK_DEFINE([__i386__]) ;;
   *x86_64*)         WINE_CHECK_DEFINE([__x86_64__]) ;;
   *alpha*)          WINE_CHECK_DEFINE([__ALPHA__]) ;;

More information about the wine-patches mailing list