Building an ARM cross compiler on OSX

We’ve tried building our own ARM cross compiler on a Linux box and it’s no picnic. Luckily there is a free cross compiling toolchain available through Mentor Graphics (formerly called Code Sourcery G++). But those looking to develop on a Mac aren’t so lucky. There is help via a script, and [Michael] wrote a guide detailing how to use crosstool-ng to build an ARM toolchain on Mountain Lion.

Crosstool-ng is a script which automates much of what is needed when compiling all the different components. But there is a some groundwork that needs to be in place before you can run it. For instance, some of the tools that ship with OSX aren’t entirely compatible with the GNU tools the script is looking for. One example is ‘grep’. Mountain Lion has the BSD version of grep but it is missing a few of the GNU version’s commands used by crosstool-ng. [Michael] will guide you through this and a handful of other issues until you have a functioning toolchain up and running.

That script pulls the sources from Mentor/CodeSourcery, so there may be changes from vanilla FSF tools. Just something to be aware of.

The script also installs/builds GCC’s dependent libraries separately, while instead you should run the script $(gcc-sources)/contrib/download_prerequisites to download the appropriate sources into the GCC source tree where they will be built as part of GCC’s normal build process.

It’s worth figuring out how to build the toolchain from scratch, by hand, so you’re not dependent on whatever scripts or pre-built versions you can find.

I just run this script. It’s very easy, the hardest part is that it’s not well explained which precise archive you want, but that’s very quickly solved with a bit of poking around (hint, it’s gcc-arm-none-eabi-4_6-2012q4-20121016-src.tar.bz2).