[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
build on MacOS X 10.5 should not add -m64
From: |
Bruno Haible |
Subject: |
build on MacOS X 10.5 should not add -m64 |
Date: |
Sun, 6 Apr 2008 06:17:33 +0200 |
User-agent: |
KMail/1.5.4 |
Hi,
When gmp 4.2.2 is configured on MacOS X 10.5 (CPU: Intel Core Duo), it
builds 64-bit libraries, which is
1. not what the user requested through the CC and CFLAGS settings
2. not the right thing, because on this system, most binaries are 32-bit.
MacOS X 10.5 is a bi-arch system. Libraries under /usr/lib contain both the
i386 and the x86_64 code ("fat binaries"):
$ file /usr/lib/libc.dylib
/usr/lib/libc.dylib: Mach-O universal binary with 4 architectures
/usr/lib/libc.dylib (for architecture ppc7400): Mach-O dynamically linked
shared library ppc
/usr/lib/libc.dylib (for architecture ppc64): Mach-O 64-bit dynamically
linked shared library ppc64
/usr/lib/libc.dylib (for architecture i386): Mach-O dynamically linked
shared library i386
/usr/lib/libc.dylib (for architecture x86_64): Mach-O 64-bit dynamically
linked shared library x86_64
gcc generates 32-bit by default:
$ gcc foo.c
$ file a.out
a.out: Mach-O executable i386
uname is 32-bit as well:
$ uname -m
i386
$ uname -p
i386
But most binaries are 32-bit:
$ file /bin/df /bin/ls /usr/bin/emacs
/bin/df: Mach-O universal binary with 2 architectures
/bin/df (for architecture i386): Mach-O executable i386
/bin/df (for architecture ppc7400): Mach-O executable ppc
/bin/ls: Mach-O universal binary with 2 architectures
/bin/ls (for architecture i386): Mach-O executable i386
/bin/ls (for architecture ppc7400): Mach-O executable ppc
/usr/bin/emacs: Mach-O universal binary with 2 architectures
/usr/bin/emacs (for architecture i386): Mach-O executable i386
/usr/bin/emacs (for architecture ppc7400): Mach-O executable ppc
$ export CC="gcc"
$ ./config.guess
core2-apple-darwin9.2.2
$ ./configure
checking build system type... core2-apple-darwin9.2.2
checking host system type... core2-apple-darwin9.2.2
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=64
checking compiler gcc -O2 -m64 ... yes
checking compiler gcc -O2 -m64 -mtune=k8... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking build system compiler gcc... yes
checking for build system preprocessor... gcc -E
checking for build system executable suffix...
checking whether build system compiler is ANSI... yes
checking for build system compiler math library... -lm
checking for egrep... grep -E
using ABI="64"
CC="gcc"
CFLAGS="-O2 -m64 -mtune=k8"
CPPFLAGS=""
MPN_PATH=" x86_64/core2 x86_64 generic"
...
$ make
...
$ file .libs/libgmp.3.4.2.dylib
.libs/libgmp.3.4.2.dylib: Mach-O 64-bit dynamically linked shared library x86_64
This is the wrong result.
gmp should obey the CC and CFLAGS settings and not add flags on its own that
cause binaries for a different ABI to be generated.
My workaround as a user is to specify a --host option. But this should not
be needed after I have specified CC and CFLAGS!
$ ./configure --host=i686-apple-darwin9.2.2
configure: WARNING: If you wanted to set the --build type, don't use --host.
If a cross compiler is detected then cross compile mode will be used.
checking build system type... core2-apple-darwin9.2.2
checking host system type... i686-apple-darwin9.2.2
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for i686-apple-darwin9.2.2-strip... no
checking for strip... strip
checking whether to enable maintainer-specific portions of Makefiles... no
checking ABI=32
checking compiler gcc -m32 -O2 -fomit-frame-pointer ... yes
checking compiler gcc -m32 -O2 -fomit-frame-pointer has sizeof(long)==4... yes
checking compiler gcc -m32 -O2 -fomit-frame-pointer -mtune=pentiumpro... yes
checking compiler gcc -m32 -O2 -fomit-frame-pointer -mtune=pentiumpro
-march=pentiumpro... yes
checking for i686-apple-darwin9.2.2-gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking build system compiler gcc... yes
checking for build system preprocessor... gcc -E
checking for build system executable suffix...
checking whether build system compiler is ANSI... yes
checking for build system compiler math library... -lm
checking for egrep... grep -E
using ABI="32"
CC="gcc"
CFLAGS="-m32 -O2 -fomit-frame-pointer -mtune=pentiumpro -march=pentiumpro"
CPPFLAGS=""
MPN_PATH=" x86/p6 x86 generic"
...
$ make
...
$ file .libs/libgmp.3.4.2.dylib
.libs/libgmp.3.4.2.dylib: Mach-O dynamically linked shared library i386
There are two mistakes in gmp-4.2.2/configure.in:
1) The fact that it adds -m32 or -m64 even when not asked for,
2) The comment here:
# AMD and Intel x86 configurations, including AMD64 ...
# -m32 forces 32-bit mode on a bi-arch 32/64 amd64 build of gcc. -m64 is
# the default in such a build (we think), ...
As explained above, -m64 is not the default on MacOS X 10.5.
Bruno
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- build on MacOS X 10.5 should not add -m64,
Bruno Haible <=