www.digitalmars.com         C & C++   DMDScript  

D.gnu - Building the arm-linux-gnueabi target

reply "Joseph Rushton Wakeling via D.gnu" <d.gnu puremagic.com> writes:
Hello all,

Is there a simple/trivial way to ensure that when I build GDC, I build not only 
the native target for my machine (x86_64) but also the arm-linux-gnueabi target?

I decided it was time to start pulling out Adam Ruppe's embedded programming 
guide, and as a decidedly non-embedded programmer, the instructions here:
http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler

... are not something I'm confident in just following (not least because e.g. 
certain scripts are provided without much indication of what they should be 
called, where they should be placed, or how to use them).

What I'd really like is just to have arm-linux-gnueabi as another target built 
in the normal process of compiling and installing GDC, not something I have to 
organize separately from my normal GDC build.

Can anyone advise?

Thanks & best wishes,

      -- Joe
Jul 13 2014
next sibling parent reply Johannes Pfau <nospam example.com> writes:
Am Sun, 13 Jul 2014 12:10:28 +0200
schrieb "Joseph Rushton Wakeling via D.gnu" <d.gnu puremagic.com>:

 Hello all,
 
 Is there a simple/trivial way to ensure that when I build GDC, I
 build not only the native target for my machine (x86_64) but also the
 arm-linux-gnueabi target?
 
 I decided it was time to start pulling out Adam Ruppe's embedded
 programming guide, and as a decidedly non-embedded programmer, the
 instructions here:
 http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler
 
 ... are not something I'm confident in just following (not least
 because e.g. certain scripts are provided without much indication of
 what they should be called, where they should be placed, or how to
 use them).
 
 What I'd really like is just to have arm-linux-gnueabi as another
 target built in the normal process of compiling and installing GDC,
 not something I have to organize separately from my normal GDC build.
 
 Can anyone advise?
 
 Thanks & best wishes,
 
       -- Joe
AFAIK that's not possible with GCC right now. One GCC build always targets one main architecture. Is there any reason why you can't use the binaries from http://gdcproject.org/downloads/ ? I assume you want a cross compiler? For native compilers on ARM machines you can just use the usual instructions: http://wiki.dlang.org/GDC/Installation/Generic For cross compilers you must build at least binutils so this is more complicated. The http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler only apply if you want an embedded compiler, i.e. you don't use linux/glibc. For linux/glibc things are even more complicated. I'll have to refer you to standard GCC-cross compiler tutorials, compiling cross-gdc is exactly the same as compiling cross-gcc. The simplest way to build such cross-compilers is with crosstool-NG: http://wiki.dlang.org/GDC/Cross_Compiler/crosstool-NG I also build the binaries at http://gdcproject.org/downloads/ with crosstool-NG.
Jul 13 2014
parent reply "Joseph Rushton Wakeling via D.gnu" <d.gnu puremagic.com> writes:
On 13/07/14 12:30, Johannes Pfau via D.gnu wrote:
 AFAIK that's not possible with GCC right now. One GCC build always
 targets one main architecture.

 Is there any reason why you can't use the binaries from
 http://gdcproject.org/downloads/ ?
No, none at all. I just thought, since I build GDC from source anyway, I might as well see if I can just add an extra couple of config options and get what I want. But it's great to have the ready-made downloads. Just to know, does the 2.065 version require that I have gcc installed 4.9.0 on my system? Or is the "GCC" column just an indicator of what GCC sources the build was based on?
 I assume you want a cross compiler? For native compilers on ARM
 machines you can just use the usual instructions:
 http://wiki.dlang.org/GDC/Installation/Generic
Yes, I'm interested principally in cross-compiling, both for linux-on-ARM and bare-metal ARM. That said, t would be fun to actually have GDC running on an RPi. I remember compiling C++ code on it and the amusing horror of how terribly long it took, it will be fun to see how D compilation goes by comparison ... :-)
 For cross compilers you must build at least binutils so this is more
 complicated. The
 http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler only
 apply if you want an embedded compiler, i.e. you don't use linux/glibc.

 For linux/glibc things are even more complicated. I'll have to refer
 you to standard GCC-cross compiler tutorials, compiling cross-gdc is
 exactly the same as compiling cross-gcc.

 The simplest way to build such cross-compilers is with crosstool-NG:
 http://wiki.dlang.org/GDC/Cross_Compiler/crosstool-NG
 I also build the binaries at http://gdcproject.org/downloads/ with
 crosstool-NG.
Thanks, I'll have a read through these. :-)
Jul 13 2014
next sibling parent reply Johannes Pfau <nospam example.com> writes:
Am Sun, 13 Jul 2014 13:17:22 +0200
schrieb "Joseph Rushton Wakeling via D.gnu" <d.gnu puremagic.com>:

 On 13/07/14 12:30, Johannes Pfau via D.gnu wrote:
 AFAIK that's not possible with GCC right now. One GCC build always
 targets one main architecture.

 Is there any reason why you can't use the binaries from
 http://gdcproject.org/downloads/ ?
No, none at all. I just thought, since I build GDC from source anyway, I might as well see if I can just add an extra couple of config options and get what I want. But it's great to have the ready-made downloads. Just to know, does the 2.065 version require that I have gcc installed 4.9.0 on my system? Or is the "GCC" column just an indicator of what GCC sources the build was based on?
It marks the build gcc version and the system gcc version should not really matter. (After all you can use cross compilers on windows or other systems which don't even have a native gcc compiler)
 
 I assume you want a cross compiler? For native compilers on ARM
 machines you can just use the usual instructions:
 http://wiki.dlang.org/GDC/Installation/Generic
Yes, I'm interested principally in cross-compiling, both for linux-on-ARM and bare-metal ARM. That said, t would be fun to actually have GDC running on an RPi. I remember compiling C++ code on it and the amusing horror of how terribly long it took, it will be fun to see how D compilation goes by comparison ... :-)
IIRC building gdc/gcc alone requires 12 hours. And you'll need swap as there's not enough ram ;-)
 
 For cross compilers you must build at least binutils so this is more
 complicated. The
 http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler
 only apply if you want an embedded compiler, i.e. you don't use
 linux/glibc.

 For linux/glibc things are even more complicated. I'll have to refer
 you to standard GCC-cross compiler tutorials, compiling cross-gdc is
 exactly the same as compiling cross-gcc.

 The simplest way to build such cross-compilers is with crosstool-NG:
 http://wiki.dlang.org/GDC/Cross_Compiler/crosstool-NG
 I also build the binaries at http://gdcproject.org/downloads/ with
 crosstool-NG.
Thanks, I'll have a read through these. :-)
Jul 13 2014
parent "Joseph Rushton Wakeling via D.gnu" <d.gnu puremagic.com> writes:
On 13/07/14 13:31, Johannes Pfau via D.gnu wrote:
 IIRC building gdc/gcc alone requires 12 hours. And you'll need swap
 as there's not enough ram ;-)
Hmmm, I'd like to think I could build gdc-for-arm itself on my regular machine and just copy it over? ;-)
Jul 13 2014
prev sibling next sibling parent "Mike" <none none.com> writes:
On Sunday, 13 July 2014 at 11:17:29 UTC, Joseph Rushton Wakeling 
via D.gnu wrote:
 The simplest way to build such cross-compilers is with 
 crosstool-NG:
 http://wiki.dlang.org/GDC/Cross_Compiler/crosstool-NG
 I also build the binaries at http://gdcproject.org/downloads/ 
 with
 crosstool-NG.
Thanks, I'll have a read through these. :-)
I ran into some trouble with crosstools. If you're going to do bare-metal, have a look at this thread as well to hopefully save yourself some frustration (http://forum.dlang.org/post/ftnzzsekkcepcthrjtdr forum.dlang.org). Mike
Jul 13 2014
prev sibling parent "Timo Sintonen" <t.sintonen luukku.com> writes:
On Sunday, 13 July 2014 at 11:17:29 UTC, Joseph Rushton Wakeling 
via D.gnu wrote:

 Yes, I'm interested principally in cross-compiling, both for 
 linux-on-ARM and bare-metal ARM.
You may also have a look at my minlibd: https://bitbucket.org/timosi/minlibd There is a minimun libdruntime suitable for arm and full toolset and working example for cortex-m4. There is lots of documentation in readme files and in wiki, including instructions how I build a cross gdc compiler. It should be easy to understand and use. If you find anything that is wrong or something you do not understand, please report it here or use the issue tracker there.
Jul 13 2014
prev sibling parent "Mike" <none none.com> writes:
On Sunday, 13 July 2014 at 10:10:34 UTC, Joseph Rushton Wakeling
via D.gnu wrote:
 I decided it was time to start pulling out Adam Ruppe's 
 embedded programming guide, and as a decidedly non-embedded 
 programmer, the instructions here:
 http://wiki.dlang.org/Bare_Metal_ARM_Cortex-M_GDC_Cross_Compiler

 ... are not something I'm confident in just following (not 
 least because e.g. certain scripts are provided without much 
 indication of what they should be called, where they should be 
 placed, or how to use them).
Those instructions came from my personal script that I use to build GDC from time-to-time. It's all one script. I broke it up in the wiki in an effort to explain the process so one could adapt it to their needs. Here's the entire script I use. I run it from within my ~/gdc folder and it installs to my ~/gdc-arm-none-eabi folder. set -e export TARGET=arm-none-eabi export PREFIX=/home/mike/gdc-arm-none-eabi 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 tar xjfv $BINUTILS_SOURCE_ARCHIVE export BINUTILS_BUILD_DIR=binutils-build rm -rf $BINUTILS_BUILD_DIR mkdir $BINUTILS_BUILD_DIR cd $BINUTILS_BUILD_DIR ../$BINUTILS_NAME/configure \ --target=$TARGET \ --prefix=$PREFIX \ --disable-nls \ --disable-multilib \ --with-gnu-as \ --with-gnu-ld \ --disable-libssp \ --disable-werror \ --enable-lto \ --enable-gold \ --enable-plugins make -j4 all make install cd .. rm -rf gdc mkdir gdc git clone https://github.com/D-Programming-GDC/GDC.git gdc cd gdc git checkout gdc-4.9 cd .. export GCC_NAME=gcc-4.9.0 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 tar xjfv $GCC_SOURCE_ARCHIVE cd gdc ./setup-gcc.sh ../$GCC_NAME cd .. export GCC_BUILD_DIR=gcc-build rm -rf $GCC_BUILD_DIR mkdir $GCC_BUILD_DIR 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-cpu=cortex-m4 \ --with-tune=cortex-m4 \ --with-mode=thumb \ --without-headers \ --enable-lto \ --enable-gold \ --enable-plugins make -j4 all-gcc make -j4 all-target-libgcc make install-gcc make install-target-libgcc cd .. This is for ARM Thumb (ARM Cortex-M), not ARM9, ARM11, ARM Cortex-A hardware. It is for the barest of bare-metal (no libc, no D runtime, no phobos, etc...), intended for those who want to actually create a D runtime. Mike
Jul 13 2014