This page describes the general installation process which should be valid for every system but does not include system specific details and tweaks. Please use the system specific installation guide for your system if available.
See Installation for an overview of installation guides.
The minimum system requirements you need to obtain and build GDC are:
- gcc and g++
- autoconf and automake
- flex and bison
For cross-compiling/multilib builds, you should also have installed:
- gcc-multilib (and maybe g++-multilib)
Run these commands in a terminal:
mkdir -p gdc/dev git clone https://github.com/D-Programming-GDC/GDC.git gdc/dev
NOTE: Master branch contains GDC compatible with GCC 4.8.x. In order to build GDC against GCC 4.7.x pick gdc-4.7 branch.
git checkout gdc-4.7
To build the D1 Compiler:
cd gdc/dev git checkout gdc-1.x cd ../
Grab GCC sources from a mirror. You will need the full gcc archives. Unpack the archives in the gdc dir. This creates something like gdc/gcc-4.7.1. Run these commands:
cd gdc/dev ./setup-gcc.sh ../gcc-4.7.1 mkdir ../objdir cd ../objdir ../gcc-4.7.1/configure --enable-languages=d --disable-bootstrap \ --prefix=/opt/gdc \ --with-bugurl="http://gdcproject.org/bugzilla" \ --enable-checking=yes make -j2 2>&1 | tee build.log # insert your number of cores in the -j argument make install export PATH=$PATH:/opt/gdc/bin
If you want to compile a release version drop --disable-bootstrap and use --enable-checking=release. Other configure arguments you might want to use:
--[enable|disable]-nls # Native language support (NLS). Lets GDC output diagnostics in languages other than English. --[enable|disable]-libgomp # Build GCC with OMP support. This is not used by GDC. --[enable|disable]-libmudflap # Build GCC with Mudflap pointer debugging support. This is not used by GDC. --[enable|disable]-libquadmath # Build GCC with 128-bit floating point support. This is not used by GDC. --[enable|disable|-libssp # Build GCC with stack smashing protection. --[enable|disable]-lto # Support link-time optimization. --[enable|disable]-ld # Build the ld linker. --[enable|disable]-gold # Build the gold linker. --[enable|disable]-multilib # Allow building both 32-bit and 64-bit apps/libs. --[enable|disable]-shared # Build shared libraries.
If you get compile errors in Ubuntu (at least x64 version) configure it with multilib (and install gcc-multilib of course).
The make command will perform the build. make install will install the compiled GDC. Use make install-strip to automatically strip symbols from the huge executables.
Since prefix is set to /opt/gdc you will install GDC there so it will not mess up with the installed GCC. Go in /opt/gdc/bin to find the GDC executable. With this source structure it will be easy to do modifications of the sources. To do changes, just modify files in gdc/d directory, it will be visible by the GCC sources. The objdir directory is used for configuration so that the GCC sources remains unmodified.
After following the instructions you can do a quick test:
goshawk@jupiter:/$ gdc -v Using built-in specs. COLLECT_GCC=gdc COLLECT_LTO_WRAPPER=/opt/gdc/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.5.3/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --enable-languages=d [...] Thread model: posix gcc version 4.5.3 20110428 (gdc hg, using dmd 2.052) (GDC 7cb42bd4eb94 DMD 2.053) goshawk@jupiter:/$ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/opt/gdc/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.5.3/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --enable-languages=d [...] Thread model: posix gcc version 4.5.3 20110428 (gdc hg, using dmd 2.052) (GDC 7cb42bd4eb94 DMD 2.053)
As you can see your current shell session will start using the newly compiled GCC and GDC, overriding but not overwriting the system default.