www.digitalmars.com         C & C++   DMDScript  

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

reply =?ISO-8859-15?Q?Andr=E9_W=F6sten?= <andre woesten.com> writes:
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: 

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 
--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 

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.
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
Feb 26 2012
parent "Mikko Ronkainen" <mikoro iki.fi> writes:
I'm having problems compiling GDC on Mac OS X 10.9.

I have setup the build with these instructions: 

Installed xcode command line tools. I have not installed full 

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 \

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" 
-B/Users/mikko/gdc/objdir/./gcc/" "CFLAGS=-g -O2" "CXXFLAGS=-g 
"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 
"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" 
"gxx_include_dir=/opt/gdc/include/c++/4.8.2" "AR=ar" 
"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 # 
make: *** [all] Error 2

Any ideas what's wrong?
Dec 18 2013