Difference between revisions of "Bare Metal ARM Cortex-M GDC Cross Compiler"

From D Wiki
Jump to: navigation, search
(Added introduction)
(Remove spacing)
Line 13: Line 13:
 
export PREFIX=/home/mike/gdc-arm-none-eabi
 
export PREFIX=/home/mike/gdc-arm-none-eabi
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Binutils ==
 
== Binutils ==
Line 50: Line 49:
 
cd ..
 
cd ..
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Download GDC ==
 
== Download GDC ==
Line 63: Line 61:
 
cd ..
 
cd ..
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Download GCC ==
 
== Download GCC ==
Line 74: Line 71:
 
rm -rf $GCC_NAME
 
rm -rf $GCC_NAME
 
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/$GCC_NAME/$GCC_SOURCE_ARCHIVE
 
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/$GCC_NAME/$GCC_SOURCE_ARCHIVE
 
  
 
# Extract GCC
 
# Extract GCC
Line 80: Line 76:
 
tar xjfv $GCC_SOURCE_ARCHIVE
 
tar xjfv $GCC_SOURCE_ARCHIVE
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Turn GCC into GDC ==
 
== Turn GCC into GDC ==
Line 90: Line 85:
 
cd ..
 
cd ..
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Build GDC ==
 
== Build GDC ==
Line 99: Line 93:
 
rm -rf $GCC_BUILD_DIR
 
rm -rf $GCC_BUILD_DIR
 
mkdir $GCC_BUILD_DIR
 
mkdir $GCC_BUILD_DIR
 
  
 
# Configure and build GDC
 
# Configure and build GDC
Line 129: Line 122:
 
make -j4 all-target-libgcc
 
make -j4 all-target-libgcc
 
</syntaxhighlight>
 
</syntaxhighlight>
 
  
 
== Install GDC ==
 
== Install GDC ==

Revision as of 09:11, 23 February 2014


Introduction

These instructions will describe how to build a bare metal ARM Cortex-M (arm-none-eabi) GDC cross compiler for a Linux host. All commands were tested on an Arch Linux 64 host. If you encounter any problems while following these instructions, you may be able to get help at the | D.GNU forum. If you can improve these instructions, please do so by making an account on this wiki and authoring changes.

These instructions were modeled after the instructions and build scripts at | GNU Tools for ARM Embedded Processors.

A C libray will not be built as this toolchain is intended for building software in pure D. The D Runtime and Phobos (the D standard library) also will not be built as these libraries have not yet been ported to the ARM Cortex-M platform. However, this toolchain should give one the tools needed to do so.

Specifying a target and installation folder

export TARGET=arm-none-eabi
export PREFIX=/home/mike/gdc-arm-none-eabi

Binutils

# Delete existing binutils source archive and download a new one
#-------------------------------------------------------------------
export BINUTILS_NAME=binutils-2.24
export BINUTILS_SOURCE_ARCHIVE=$BINUTILS_NAME.tar.bz2
rm -f $BINUTILS_SOURCE_ARCHIVE
rm -rf $BINUTILS_NAME
wget http://ftpmirror.gnu.org/binutils/$BINUTILS_SOURCE_ARCHIVE

# Extract binutils
#-------------------------------------------------------------------
tar xjfv $BINUTILS_SOURCE_ARCHIVE

# Create binutils build directory
#-------------------------------------------------------------------
export BINUTILS_BUILD_DIR=binutils-build
rm -rf $BINUTILS_BUILD_DIR
mkdir $BINUTILS_BUILD_DIR

# Configure and build binutils
#-------------------------------------------------------------------
cd $BINUTILS_BUILD_DIR
../$BINUTILS_NAME/configure \
  --target=$TARGET   \
  --prefix=$PREFIX   \
  --disable-nls      \
  --disable-multilib \
  --with-gnu-as      \
  --with-gnu-ld      \
  --disable-libssp   
make -j4 all
make install
cd ..

Download GDC

# Download GDC
#-------------------------------------------------------------------
rm -rf gdc
mkdir gdc
git clone https://github.com/D-Programming-GDC/GDC.git gdc
cd gdc
git checkout gdc-4.8
cd ..

Download GCC

# Delete existing GCC source archive and download a new one
#-------------------------------------------------------------------
export GCC_NAME=gcc-4.8.2
export GCC_SOURCE_ARCHIVE=$GCC_NAME.tar.bz2
rm -f $GCC_SOURCE_ARCHIVE
rm -rf $GCC_NAME
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/$GCC_NAME/$GCC_SOURCE_ARCHIVE

# Extract GCC
#-------------------------------------------------------------------
tar xjfv $GCC_SOURCE_ARCHIVE

Turn GCC into GDC

# Turn GCC into GDC
#-------------------------------------------------------------------
cd gdc
./setup-gcc.sh ../$GCC_NAME
cd ..

Build GDC

# Create GDC build directory
#-------------------------------------------------------------------
export GCC_BUILD_DIR=gcc-build
rm -rf $GCC_BUILD_DIR
mkdir $GCC_BUILD_DIR

# Configure and build GDC
#-------------------------------------------------------------------
cd $GCC_BUILD_DIR
../$GCC_NAME/configure --target=$TARGET --prefix=$PREFIX \
  --enable-languages=d     \
  --disable-bootstrap      \
  --disable-libssp         \
  --disable-libgomp        \
  --disable-libmudflap     \
  --disable-multilib       \
  --disable-libphobos      \
  --disable-decimal-float  \
  --disable-libffi         \
  --disable-libmudflap     \
  --disable-libquadmath    \
  --disable-libssp         \
  --disable-libstdcxx-pch  \
  --disable-nls            \
  --disable-shared         \
  --disable-threads        \
  --disable-tls            \
  --with-gnu-as            \
  --with-gnu-ld            \
  --with-mode=thumb        \
  --without-headers
make -j4 all-gcc
make -j4 all-target-libgcc

Install GDC

make install-gcc
make install-target-libgcc
cd ..