Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

GDC Installation

This page only sums up information from elsewhere and is only reference material for other parts of the Tango documentation.

GDC Installation from binary distribution

The binary distribution of GDC can be retrieved at SourceForge. Chose the appropriate file according to what operating system you run. The archives are all bzipped, which means you need either bunzip2, or another program that supports the format.

All archives have a common structure according to the directories you find in /usr on a common Unix-like operating system:

  • gdc/
    • bin/
    • include/
    • lib/
    • libexec/
    • man/
    • share/

The easiest way to achieve a correct installation of GDC is to just copy the whole content of the gdc/ directory into a directory of your choice (/usr/local or /usr, if you have root access to your development/evaluation machine).

If you feel like doing a special installation, be aware of the fact that this could lead to a corrupt or not fully functional installation.

Prerequisites

You need at least these programs installed for the next steps. Most of them are probably already installed.

  • curl
  • bunzip2
  • tar
  • patch
  • svn (subversion)
  • c++ (or g++; you may want to do "ln -s /usr/bin/g++ /usr/bin/c++")

GDC Installation from source

These instructions apply for the SourceForge Subversion GDC repository. In case you already have GDC installed in an appropriate version, you can skip this section.

Getting GCC

Get the GCC sources from http://gcc.gnu.org/. You need at least the gcc-core-x.x.x file, or the gcc-x.x.x file if you want the full GCC collection. For this document, it is assumed that you have gcc-core-4.1.2.tar.bz2 and gcc-g++-4.1.2.tar.bz2.

$ curl ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.1.2/gcc-core-4.1.2.tar.bz2 -o gcc-core-4.1.2.tar.bz2 
$ curl ftp://ftp.fu-berlin.de/unix/languages/gcc/releases/gcc-4.1.2/gcc-g++-4.1.2.tar.bz2 -o gcc-g++-4.1.2.tar.bz2 

Note: Currently only tested up to GCC 4.1.2.
GDC does not work with GCC 4.2.x (there are only some half-baked patches atm., 07.2008).

Getting GDC

If you want the latest D features, use the trunk directory. You will find the latest branch in the branches directory of your GDC sources, but it may be outdated.

For trunk you would do

svn co https://dgcc.svn.sourceforge.net/svnroot/dgcc/trunk/d

which creates the d directory.

Compiling GDC

This will be shown keeping separate directories for the sources and the compiled binaries.

1. Extract the GCC sources to an empty directory

$ mkdir gdc-sf
$ cd gdc-sf
$ tar xjf ../gcc-core-4.1.2.tar.bz2 
$ tar xjf ../gcc-g++-4.1.2.tar.bz2 

on Macintosh 10.5 you have to change "--strip-underscores" to "--strip-underscore" in "gcc-4.1.2/libstdc++-v3/scripts/make_exports.pl".

2. Copy the GDC sources to the GCC directory, and run the setup script.

$ cd gcc-4.1.2/gcc
$ cp -R ../../../d .
$ cd ..
$ gcc/d/setup-gcc.sh

3. Create a new empty directory for building.

$ cd ..
$ mkdir build
$ cd build

4. Configure, make, make install; Don't forget to enable all languages you want to use.

$ ../gcc-4.1.2/configure --enable-languages=c,c++,d
$ make
$ sudo make install

On macintosh you might want to replace the previous commands with

$ ../gcc-4.1.2/configure --prefix=$HOME/d/gdc024 --disable-nls --disable-multilib --enable-languages=c,c++,d
$ make
$ sudo make install
$ echo export PATH=/Users/pkgs/gdc024/bin:$PATH > $HOME/d/gdc_setup.sh
$ echo export LD_LIBRARY_PATH=/Users/pkgs/gdc024/lib:$LD_LIBRARY_PATH >> $HOME/d/gdc_setup.sh

so that wherever you want to use gdc you just need to

$ . ~/d/gdc_setup.sh

(the ". " is important in that command). If you always want to use gdc add the previous line to your ~/.profile or ~/.bashrc

5. Test

$ gdc --version

Comments
Author Message

Posted: 05/07/08 16:08:41 -- Modified: 08/22/08 12:29:14 by
mandel -- Modified 9 Times

Error workaround

If you get a message about "configure: error: can't compile D sources!" and "version `GCC_4.2.0' not found",
then add "--enable-static --disable-shared" to your configure call.
Don't forget to clean up your build directory completely.

Local Installation

For a local install you can to add "--prefix=/home/user/local" to the configure call.
"make install" will place the gdc files into that folder.

To use gdc you have to add it to PATH:
"export PATH=$PATH:/home/user/local/bin".

For use with Tango you need also to replace the included Phobos files with Tango files:
Replace ~/local/include/d/4.1.2/[object.d,std/] with object.d, std/ and tango/ from the Tango repository.
Also replace ~/local/lib/libgphobos.a with libgphobos.a and libgtango.a build by build-gdc.sh
in lib/ directory of the Tango repository.

Here you go:

gdc foo.d -o foo -fversion=Posix -fversion=Tango -I/home/user/local/include/d/4.1.2 -L/home/user/local/lib -lgtango

D 2.0

Tango is D 1.0 only atm., but if you want gdc to support D 2.0 you have to do:

gcc/d/setup-gcc.sh --d-language-version=2

Optimization

Here are some gdc parameters for some optimization:

-ffast-math -O3 -frelease -finline-functions -msse -mfpmath=sse -femit-templates=all