GDC/Development/DevelopmentEnvironment
Contents
Creating a Development Environment for Hacking and Debugging GDC
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)
Creating a Directory Structure
These instructions will do a native build. If you wish to build a cross-compiler, see GDC/Cross_Compiler and modify these scripts and instructions per your target's requirements.
These instructions will use the following directory structure.
$HOME/ gdc-src/ gdc/ gcc/ build/ usr/
$HOME/gdc-src/gdc/
- This directory will contain the GDC source code downloaded from a GCC mirror$HOME/gdc-src/gcc/
- This directory will contain the GCC source code clone from the GDC GitHub repository$HOME/gdc-src/build/
-configure
should not be run within the$HOME/gdc-src/gcc/
directory, so$HOME/gdc-src/build/
will be used to for runningconfigure
andmake
$HOME/usr/
- This directory will contain the final GDC toolchain binaries, libraries, etc...
Run the following commands to create the directory structure
mkdir $HOME/gdc-src/
mkdir $HOME/gdc-src/gdc/
mkdir $HOME/gdc-src/gcc/
mkdir $HOME/gdc-src/build/
mkdir $HOME/usr/
Obtain the GCC Source Code and Extract it to $HOME/gdc-src/gcc/
cd $HOME/gdc-src/
export GCC_MIRROR=http://ftp.tsukuba.wide.ad.jp/software/gcc/releases
export GCC_NAME=gcc-4.9.1
export GCC_SOURCE_ARCHIVE=$GCC_NAME.tar.bz2
wget $GCC_MIRROR/$GCC_NAME/$GCC_SOURCE_ARCHIVE
tar xjfv $GCC_SOURCE_ARCHIVE -C gcc
rm $GCC_SOURCE_ARCHIVE
You may wish to use an alternate GCC mirror.
Obtain the GDC Source Code
cd $HOME/gdc-src/gdc/
git clone https://github.com/D-Programming-GDC/GDC.git .
git checkout gdc-4.9
If you plan on submitting pull requests, may want to first fork the GDC GitHub repository, and then clone from your fork.
Add GDC to GCC
cd $HOME/gdc-src/gdc/
./setup-gcc.sh ../gcc
Configure GCC
cd $HOME/gdc-src/build/
../gcc/configure \
--enable-languages=d \
--disable-bootstrap \
--prefix=/usr \
--disable-multilib \
--disable-libgomp \
--disable-libmudflap \
--disable-libquadmath
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|-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.
--with-multilib-list=mXX,mYY # Select multilibs, eg: --with-multilib-list=m32,m64,mx32 (AArch64 and x86-64 only)
Documentation on the various configure options can be found in GCC's documentation here
Build GCC
cd $HOME/gdc-src/build/
make CXXFLAGS="-g3 -O0" -j2 2>&1 | tee build.log
Install GCC
cd $HOME/gdc-src/build/
export DESTDIR=$HOME
make install