www.digitalmars.com         C & C++   DMDScript  

D.gnu - Build script for a cross compiler

reply "Timo Sintonen" <t.sintonen luukku.com> writes:
People have been asking a build script Here is one I have
written. This was originally ment to build gdc in a virtual
machine but I did not get this to work in a vm. There were always
missing something or some issues like 32/64 bit mismatch.

This script gets the current head of gdc, loads the required gcc
version, pacthes it and configures for ARM. In addition, a file
to put in t-arm-elf is needed.

If you like, please test and report. If this is useful we may
then put this to wiki.

----8<----

#!/bin/bash

# This script compiles and installs tgdc

# Additional programs. Usually they are already installed but
# a virtual machine does not have these.
sudo apt-get install gcc g++ git libgmp-dev libmpfr-dev
libmpc-dev \
   binutils-dev flex

cd
rm -rf gdc
mkdir -p gdc
cd gdc

# Binutils
wget
ftp://ftp.funet.fi/pub/mirrors/ftp.gnu.org/pub/gnu/binutils/binutils-2.25.tar.gz
tar zxvf binutils-2.25.tar.gz
cd binutils-2.25
./configure --target=arm-eabi --disable-nls
make
sudo make install
cd ..

# GDC
git clone git://github.com/D-Programming-GDC/GDC gdc
gccver=`cat gdc/gcc.version`
gccdir=`cat gdc/gcc.version | cut -c5-`

# GCC
wget ftp://gcc.gnu.org/pub/gcc/snapshots/$gccdir/$gccver.tar.bz2
tar jxvf $gccver.tar.bz2

# Patch gcc
cd gdc
#./setup-gcc.sh ../$gccver
cd ..

# Patch t-arm-elf
cp  t-arm-elf.own  $gccver/gcc/config/arm/t-arm-elf

# GCC compilation
# MOdify the flags for your system
mkdir build-gcc
cd build-gcc
../$gccver/configure --target=arm-eabi --disable-bootstrap \
    --enable-languages=c --enable-multilib --disable-nls \
    --without-isl --without-cloog \
    --without-gmp --without-mpfr --without-mpc \
    --disable-libphobos

make
sudo make install
------->8------

And this is what to put in t-arm.elf.own:
-------
MULTILIB_OPTIONS  += mcpu=cortex-m0/mcpu=cortex-m3/mcpu=cortex-m4
   mfloat-abi=hard mfpu=fpv4-sp-d16
MULTILIB_DIRNAMES += cortex-m0 cortex-m3 cortex-m4
MULTILIB_REQUIRED += mcpu=cortex-m0
MULTILIB_REQUIRED += mcpu=cortex-m3
MULTILIB_REQUIRED += mcpu=cortex-m4 /mfloat-abi=hard
/mfpu=fpv4-sp-d16
MULTILIB_EXTRA_OPTS += mthumb

----------
Apr 27 2015
next sibling parent "Mike" <none none.com> writes:
On Tuesday, 28 April 2015 at 05:00:50 UTC, Timo Sintonen wrote:

 ../$gccver/configure --target=arm-eabi --disable-bootstrap \
    --enable-languages=c --enable-multilib --disable-nls \
    --without-isl --without-cloog \
    --without-gmp --without-mpfr --without-mpc \
    --disable-libphobos
I think that should be --enable-languages=d. Is c necessary?
Apr 27 2015
prev sibling next sibling parent "Iain Buclaw via D.gnu" <d.gnu puremagic.com> writes:
On 28 April 2015 at 07:00, Timo Sintonen via D.gnu <d.gnu puremagic.com> wrote:
 People have been asking a build script Here is one I have
 written. This was originally ment to build gdc in a virtual
 machine but I did not get this to work in a vm. There were always
 missing something or some issues like 32/64 bit mismatch.

 This script gets the current head of gdc, loads the required gcc
 version, pacthes it and configures for ARM. In addition, a file
 to put in t-arm-elf is needed.

 If you like, please test and report. If this is useful we may
 then put this to wiki.

 ----8<----

 #!/bin/bash

 # This script compiles and installs tgdc

 # Additional programs. Usually they are already installed but
 # a virtual machine does not have these.
 sudo apt-get install gcc g++ git libgmp-dev libmpfr-dev
 libmpc-dev \
   binutils-dev flex
As an alternative (or if for some reason you are running an older OS), rather than installing libgmp/mpfr/mpc through the repositories, you can use ./contrib/download_prerequisites script in gcc sources. https://github.com/ibuclaw/docker-gdc/blob/2fc174504a952aee9ab8f7285fb2cd5f1a9a90d8/5.0/Dockerfile Iain.
Apr 27 2015
prev sibling parent reply "Jens Bauer" <doctor who.no> writes:
On Tuesday, 28 April 2015 at 05:00:50 UTC, Timo Sintonen wrote:
 People have been asking a build script Here is one I have
 written. This was originally ment to build gdc in a virtual
 machine but I did not get this to work in a vm. There were 
 always
 missing something or some issues like 32/64 bit mismatch.

 If you like, please test and report.
I tried on Cubian (Debian variant for CubieBoard2), but it failed attempting to build gcc-6-20150412.
 # GDC
 git clone git://github.com/D-Programming-GDC/GDC gdc
 gccver=`cat gdc/gcc.version`
 gccdir=`cat gdc/gcc.version | cut -c5-`
Note: If checking out gdc-4.9, this does not use the latest build. Instead you will get gcc-4.9.0, which is buggy and absolutely not recommended.
 # Patch gcc
 cd gdc
 #./setup-gcc.sh ../$gccver
The last line should of course be enabled. ;)
 # Patch t-arm-elf
 cp  t-arm-elf.own  $gccver/gcc/config/arm/t-arm-elf

 # GCC compilation
{snip}
 make
make fails on my CubieBoard2. These are the last lines I see: http://pastebin.com/Zdp0QAte (Note: I did not press control-C; the script terminated by itself)
May 02 2015
parent reply "Jens Bauer" <doctor who.no> writes:
On Sunday, 3 May 2015 at 05:51:55 UTC, Jens Bauer wrote:
 On Tuesday, 28 April 2015 at 05:00:50 UTC, Timo Sintonen wrote:
 People have been asking a build script Here is one I have
 written. This was originally ment to build gdc in a virtual
 machine but I did not get this to work in a vm. There were 
 always
 missing something or some issues like 32/64 bit mismatch.

 If you like, please test and report.
I tried on Cubian (Debian variant for CubieBoard2), but {snip} make fails {snip}
It seems I can't build any GCC (not even a native GCC without GDC) on CubieBoard2. -So I expect I'm missing some tools. I do have flex, bison, autotools and libtool installed; and I also have gmp/mpc/mpfr, so it must be something else.
May 03 2015
parent "Jens Bauer" <doctor who.no> writes:
On Sunday, 3 May 2015 at 10:38:14 UTC, Jens Bauer wrote:
 On Sunday, 3 May 2015 at 05:51:55 UTC, Jens Bauer wrote:
 If you like, please test and report.
I tried on Cubian (Debian variant for CubieBoard2), but {snip} make fails {snip}
I've polished my own build-script/build-instructions. So far, this is the only thing that will work on a PowerMac with Mac OS X. It does not work on Cubian. It does not work on Debian. It *might* work on Mac OS X with intel, but I do not know. My build-script/instructions will result in a toolchain supporting C/C++/D AND stdlibc++. Thus I can now finally build my old projects AND have D at the same time; no compromises (except from that the compiler is only built once, not twice, but that's considered acceptable). Even though my guide will not work out-of-the-box on Linux or other systems, it might serve as an approximate how-to / way to get past problems (I've got 5 years of experience in making ARM toolchains). http://d.gpio.dk/dl/Build%20a%20GDC%20toolchain.pdf If using the script (or using the guide as a script), 3 optional parameters can be supplied: 1: workdir (a temporary directory for containing sources and builds). 2: prefix: For instance /usr/local - default is to install in $workdir/Install 3: toolchain name; If building a package, this will be appended to prefix: /usr/local/myTools
May 03 2015