February 26, 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
December 18, 2013
I'm having problems compiling GDC on Mac OS X 10.9.

I have setup the build with these instructions: http://gdcproject.org/wiki/Installation/General

Installed xcode command line tools. I have not installed full Xcode.

Installed GCC 4.8 from macports and set it as default gcc (gcc -v says gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)).

Checked out gdc-4.8 branch.

Downloaded gcc-4.8.2 sources, ran setup-gcc.sh.

Commented out the AVX stuff as mentioned above.

Configured and built in a separate directory with:

../gcc-4.8.2/configure \
--prefix=/opt/gdc \
--enable-languages=d \
--disable-bootstrap \
--enable-checking=yes \
--disable-multilib \
--disable-nls \
--disable-libgomp \
--disable-libmudflap \
--with-gmp=/opt/local \
--with-mpfr=/opt/local \
--with-mpc=/opt/local \
--with-system-zlib=/opt/local

I have no idea at what stage does the build fail, but here are the last lines:

Making all in doc
make[4]: Nothing to be done for `all'.
Making all in po
make[4]: Nothing to be done for `all'.
Making all in testsuite
make[4]: Nothing to be done for `all'.
Making all in python
sed -e 's,@pythondir@,/opt/gdc/share/gcc-4.8.2/python,' \
	    -e 's,@toolexeclibdir@,/opt/gdc/lib,' < ../../../../gcc-4.8.2/libstdc++-v3/python/hook.in > gdb.py
true "AR_FLAGS=rc" "CC_FOR_BUILD=gcc" "CC_FOR_TARGET=/Users/mikko/gdc/objdir/./gcc/xgcc -B/Users/mikko/gdc/objdir/./gcc/" "CFLAGS=-g -O2" "CXXFLAGS=-g -O2" "CFLAGS_FOR_BUILD=-g -O2" "CFLAGS_FOR_TARGET=-g -O2" "INSTALL=/usr/bin/install -c" "INSTALL_DATA=/usr/bin/install -c -m 644" "INSTALL_PROGRAM=/usr/bin/install -c" "INSTALL_SCRIPT=/usr/bin/install -c" "LDFLAGS=" "LIBCFLAGS=-g -O2" "LIBCFLAGS_FOR_TARGET=-g -O2" "MAKE=/Library/Developer/CommandLineTools/usr/bin/make" "MAKEINFO=makeinfo --split-size=5000000 --split-size=5000000   " "SHELL=/bin/sh" "RUNTESTFLAGS=" "exec_prefix=/opt/gdc" "infodir=/opt/gdc/share/info" "libdir=/opt/gdc/lib" "includedir=/opt/gdc/include" "prefix=/opt/gdc" "tooldir=/opt/gdc/x86_64-apple-darwin13.0.0" "gxx_include_dir=/opt/gdc/include/c++/4.8.2" "AR=ar" "AS=/Users/mikko/gdc/objdir/./gcc/as" "LD=/Users/mikko/gdc/objdir/./gcc/collect-ld" "RANLIB=ranlib" "NM=/Users/mikko/gdc/objdir/./gcc/nm" "NM_FOR_BUILD=" "NM_FOR_TARGET=nm" "DESTDIR=" "WERROR=" DO=all multi-do # /Library/Developer/CommandLineTools/usr/bin/make
make: *** [all] Error 2

Any ideas what's wrong?