HowTo: Compiling GDC (v2) on Mac OS X Lion (10.7.x)

André Wösten andre at woesten.com
Sun Feb 26 03:23:48 PST 2012


Hi there,

just want to inform the list for whoever who's interested how to compile 
GDC on Mac OS X Lion because it was tricky.

The first steps do as explained here: 
https://bitbucket.org/goshawk/gdc/wiki/Home#!installation

Be sure to have the libraries installed via MacPorts. Clone the 
repository, download and unpack gcc.

Before configuring, completely disable the AVX check in the i386 GCC 
driver by editing gcc/config/i386/driver-i386.c commenting out the line

has_avx = ecx & bit_AVX;

We have to do this because the assembler (as) delivered with MacOS 
doesn't support AVX. You could also try to use clang as assembler but it 
doesn't support the full AVX instruction set. Also you could try the 
binutils of MacPorts (GAS), but this doesn't - unfortunately - support 
reliable Mach-O output :-(

Now use as configure line:

./configure --enable-languages=d --disable-bootstrap --disable-nls 
--prefix=/opt/local 
--with-bugurl="https://bitbucket.org/goshawk/gdc/issues" 
--enable-checking=yes --disable-libgomp --disable-libmudflap 
--with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local 
--with-arch=native --with-system-zlib=/opt/local --disable-multilib 
--enable-fully-dynamic-string

This may not be perfect, but it works. --with-system-zlib is necessary 
if you don't want the famous GCC_NO_EXECUTABLES error. The paths have to 
point into your MacPorts installation directory (with gmp, mpfr and 
libmpc). And what's most important: The whole GCC configuration won't 
work with --disable-shared. I don't know why but it just works without. 
--enable-fully-dynamic-string is necessary because the system libs of 
Mac OS also seem to use this - otherwise you would get memory errors.

Build the monster with
make -j2 2>&1 | tee build.log

and install with
make install

and you'll get a clean installation:

--- %< ---

andres-macbook-pro:objdir aw$ gdc -v
Using built-in specs.
COLLECT_GCC=gdc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin11.3.0/4.6.2/lto-wrapper
Target: x86_64-apple-darwin11.3.0
Thread model: posix
gcc version 4.6.2 20111026 (gdc 0.31 - r796:f4b81c81e760, using dmd 
2.057) (GCC)

--- >% ---

Hope this helps! :-)

Best regards,
André Wösten


More information about the D.gnu mailing list