------- Comment #28 from joseph at codesourcery dot com  2009-09-03 11:04 
-------
Subject: Re:  can not build gcc 4.4.1 on Snow Leopard
 Mac OS X 10.6

On Thu, 3 Sep 2009, howarth at nitro dot med dot uc dot edu wrote:

> Mike,
>      Regarding passing -m32 within the x86_64 host case, I was considering the
> case of trying to cross compile the i686-apple-darwin10 target on the
> x86_64-apple-darwin10 host.  While this sounds odd, we currently do this on
> i386 fink for 10.6 (but we cheat by using wrappers for the compilers that pass
> -m32 and explicitly pass --build=i686-apple-darwin10 
> --host=i686-apple-darwin10
>  --target=i686-apple-darwin10 to gcc's configure). Without my proposed patch 
> in
> comment 10, if the user passed...
> 
> --host=x86_64-apple-darwin10 --target=i686-apple-darwin10
> 
> the i[[3456789]]86-*-darwin* host case won't be triggered but rather the 
> absent
> x86_64-*-darwin* host case. Without the patch, no -m32 will be added to CC
> and the compiler will attempt to build the i686-apple-darwin10 compiler with
> the default m64 code generation. 

If you pass those options, you are asking for the compiler that is built 
to be a 64-bit binary itself, but to default to generating 32-bit code.  
CC at top level is the compiler for the host, so should be a 64-bit 
compiler and no -m32 should be added; adding -m32 is actually *wrong* 
here.  No pre-existing compiler generating 32-bit code is required by this 
configuration (presuming that the build system is also 
x86_64-apple-darwin10, the same as the host).  If you wanted a compiler 
that was a 32-bit binary, as well as generating 32-bit code, you'd specify 
--host=i686-apple-darwin10, and pass a 32-bit CC setting.

> If I remove the change from comment 20 and use the stock configure from gcc
> trunk with...
> 
> ../gcc/configure --prefix=/Users/howarth/dist
> --enable-languages=c,c++,fortran,objc,java --with-arch=nocona
> --with-tune=generic --host=x86_64-apple-darwin10 --target=i686-apple-darwin9
> --with-gmp=/sw --with-libiconv-prefix=/sw --with-system-zlib
> --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib
> 
> where /sw is a i386 fink installation containing i386 binaries for gmp/mpfr, I
> get the configure failure...
> 
> checking for correct version of gmp.h... yes
> checking for correct version of mpfr.h... yes
> checking for the correct version of mpc.h... no
> checking for the correct version of the gmp/mpfr libraries... no
> configure: error: Building GCC requires GMP 4.2+ and MPFR 2.3.2+.
> Try the --with-gmp and/or --with-mpfr options to specify their locations.

If you are using --host=x86_64-apple-darwin10, you clearly need 64-bit 
copies of GMP and MPFR in the appropriate locations.

> Adding Apple's patch as...
> 
> @@ -3645,6 +3653,12 @@
>    powerpc-*-darwin*)
>      host_makefile_frag="config/mh-ppc-darwin"
>      ;;
> +  i[3456789]86-*-darwin*)
> +    # gcc can default to x86_64 code generation, avoid that
> +    if test "${build}" = "${host}"; then
> +         CC="${CC-gcc} -m32"
> +    fi
> +    ;;

This also seems wrong (or at least unnecessary).  If the user configures 
--host=i686-apple-darwin10 when the host compiler defaults to 64-bit code 
generation, the user has passed incorrect configure options.  It is the 
responsibility of the user in that case to set CC="gcc -m32", not the 
responsibility of GCC.  This is just the same as if you wish to bootstrap 
a 32-bit compiler on x86_64-linux-gnu: you have to set CC appropriately 
yourself, as well as passing suitable configure options.  Such a bootstrap 
works fine, and if you are doing something different here for Darwin from 
what is done for the GNU/Linux case that is a good sign you are doing 
something wrong.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41180

Reply via email to