GDC/Installation/Generic

From D Wiki
Revision as of 10:23, 6 July 2013 by Jpf (talk | contribs) (Created page with "This page describes the generic installation process which should be valid for every system but does not include system specific details and tweaks. Please use the system spec...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page describes the generic installation process which should be valid for every system but does not include system specific details and tweaks. Please use the system specific installation guides for your system if available.

Prerequesites

The minimum system requirements you need to obtain and build GDC are:

  • gcc and g++
  • libmpc-dev
  • libmpfr-dev
  • libgmp3-dev
  • autoconf and automake
  • flex and bison
  • patch
  • git

For cross-compiling/multilib builds, you should also have installed:

  • gcc-multilib
  • (maybe g++-multilib)

Building

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.9.x. In order to build GDC against GCC 4.8.x pick gdc-4.8 branch, for GCC 4.7.x use gdc-4.7:

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.

Updating an existing build

If you have a setup as described above and want to build a newer gdc version you don't have to do all steps again:

cd gdc/dev
./setup-gcc.sh --update ../gcc-4.7.1
cd ../objdir
make -j2 2>&1 | tee build.log                            # insert your number of cores in the -j argument
make install