Tag Archives: gcc 5.2

Building a toolchain

We’d like to use features offered by the latest C++ standards, so we need a state-of-the-art compiler;  gcc seems to be a natural choice. Since we need libc as well, and also having additional tools like gdb would be nice, it was decided to use http://crosstool-ng.org/. The only problem was that the host OS is Mac OS 10.11 El Capitan. It appears that building an ARM toolchain for it with crosstool-ng doesn’t work straight away:

  1.  binutil 2.25.x has a bug: a valid ARM assembler code doesn’t compile complaining about “invalid constant (xx) after fixup” – this can be fixed by applying the following patch: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=d840c081f8082e8b9e63fead5306643975a97bb3
  2.  <binutils>/gold/binary.cc: add ‘#include <string>” before ‘#include “safe-ctype.h”‘
  3.  <binutils>/gold/gold-theads.cc: once_(PTHREAD_ONCE_INIT) in the initializer list fails to compile; I just replaced it with the following:
  4. class Once_initialize
    {
    public:
    Once_initialize()
    { once_.__sig = 0x30B1BCBA; once_.__opaque[0] = 0; }
  5. dmalloclib fails to build – cross-compiling under Mac OS is not supported, just disable it in .config
  6.  strace doesn’t compile – perhaps it can be fixed by applying this patch: http://sourceforge.net/p/strace/mailman/message/32937648/ but we don’t plan to use it (at least at this stage) so it was disabled in .config.

The resulting ARM Cortex A8/Linux 4.3.1 cross toolchain (gcc 5.2, libc and some other useful software like gdbserver and gdb) for Mac OS 10.11 El Capitan (it should work in Mac OS 10.10 Yosemite, but I didn’t try) can be downloaded from here:

ARM Cortex A8/Linux 4.3.1 toolchain for Mac OS X built with ‘softfp’ FPU

SHA1: 25854b78b396b30fccde1e886ab6e73a7f677985

crosstool-ng configuration file

ARM Cortex A8/Linux 4.3.1 toolchain for Mac OS X built with hardware FPU support

SHA1: ff6ceddf39eb8d1ee35b1f3ef6fafd2745567996

Linux kernel 4.3.1 headers