Author: Mugabi Siro

Category: GNU/Linux Toolchain

Summary:

This entry covers obtaining the Linaro GNU/Linux ARM cross-toolchain. Tested on Ubuntu 12.04/14.04 (AMD64).

Tags: gnu/linux toolchain gnu linux qemu cross-compiling arm

Overview

The Linaro Toolchain Working Group deals with all aspects of system-level tools: Core development toolchain (compiler, assembler, linker and debugger), emulation (qemu-linaro), profiling and analysis (oprofile, performance events) and instrumentation (ftrace). Linaro Toolchain is the umbrella project for all Lauchpad projects by the Linaro Toolchain Working Group.

With respect to the core development toolchain, the team focuses on releasing optimized GNU/Linux toolchains for recent ARM CPUs. The toolchain discussed in this guide targets a qemu-linaro emulated ARM machine. See qemu-system-arm, howto for an introduction to qemu_linaro.

Obtaining a Pre-Built Linaro ARM Cross-Toolchain Package

Direct Download

Pre-compiled binaries of Linaro cross-toolchains can be downloaded from here. According to this and this, (update) releases of these binaries are "made on the third to last Thursday of each month".

The GNU/Linux toolchain versions are supported on Debian 6.0.2, Ubuntu, Fedora 16, openSUSE 12.1, Red Hat Enterprise Linux Workstation 5.7 and later, and should run on any Linux Standard Base 3.0 compatible distribution (32/64-bit).

Ubuntu Repositories

As of Maverick (10.10), the *-arm-linux-gnueabi package is available from the universe repository:

$ sudo apt-get install gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf

where:

  • gcc-arm-linux-gnueabi is the cross-toolchain package for the armel architecture. This toolchain implies the EABI generated by gcc's -mfloat-abi=soft or -mfloat-abi=softfp options.

  • gcc-arm-linux-gnueabihf is the cross-toolchain package for the armhf architecture. This toolchain implies the EABI generated by the gcc -mfloat-abi=hard option. This version will be required for building the QEMU target's userspace applications.

    Replace gcc with g++, gfortran, etc as needed.

A few notable files and directories created during the installation include:

$  $ ls -CF /usr/bin/ | grep arm-linux-gnueabi
arm-linux-gnueabi-addr2line*
arm-linux-gnueabi-ar*
arm-linux-gnueabi-as*
(...)
arm-linux-gnueabi-elfedit*
arm-linux-gnueabi-g++@
arm-linux-gnueabi-g++-4.7*
arm-linux-gnueabi-gcc@
arm-linux-gnueabi-gcc-4.7*
(...)
arm-linux-gnueabihf-ar*
arm-linux-gnueabihf-as*
(...)
arm-linux-gnueabihf-elfedit*
arm-linux-gnueabihf-g++@
arm-linux-gnueabihf-g++-4.8*
arm-linux-gnueabihf-gcc@
arm-linux-gnueabihf-gcc-4.8*
(...)
arm-linux-gnueabihf-nm*
arm-linux-gnueabihf-objcopy*
arm-linux-gnueabihf-objdump*
arm-linux-gnueabihf-ranlib*
arm-linux-gnueabihf-readelf*
(...)
arm-linux-gnueabi-nm*
arm-linux-gnueabi-objcopy*
arm-linux-gnueabi-objdump*
arm-linux-gnueabi-ranlib*
arm-linux-gnueabi-readelf*
(...)

$ ls -l /usr/arm-linux-gnueabi*
/usr/arm-linux-gnueabi:
total 12
drwxrwxr-x  2 root root 4096 23 22:30 bin
drwxr-xr-x 32 root root 4096 24 00:51 include
drwxr-xr-x  2 root root 4096 24 00:51 lib

/usr/arm-linux-gnueabihf:
total 16
drwxrwxr-x  2 root root 4096 23 22:30 bin
drwxr-xr-x 32 root root 4096 24 00:51 include
drwxr-xr-x  2 root root 4096 24 00:51 lib
drwxrwxr-x  2 root root 4096 24 00:51 libsf

The following command helps in locating the path and name of the installed cross-compiler executable and miscellaneous related files in Ubuntu/Debian:

$ dpkg -L gcc-arm-linux-gnueabi[hf]
/.
/usr
/usr/share
/usr/share/doc
/usr/share/man
/usr/share/man/man1
/usr/bin
/usr/share/doc/gcc-arm-linux-gnueabi[hf]
/usr/share/man/man1/arm-linux-gnueabi[hf]-gcov.1.gz
/usr/share/man/man1/arm-linux-gnueabi[hf]-gcc.1.gz
/usr/bin/arm-linux-gnueabi[hf]-gcov
/usr/bin/arm-linux-gnueabi[hf]-gcc

Linaro Backports

Linaro's latest contributions to mainline GCC are also backported to stable GCC versions - whenever possible.

  • Ubuntu Backports PPA

    Backports for older Ubuntu releases, e.g. Lucid (10.04), can be obtained via:

    $ sudo add-apt-repository ppa:linaro-maintainers/toolchain
    $ sudo apt-get update
    $ sudo apt-get install gcc-arm-linux-gnueabi
    

    Replace gcc with g++/gfortran/gobjc/gobjc++ as needed.

    Visit this PPA site for more details.

Determining Pre-compiled Toolchain C Library Version Info

For instance, with an Ubuntu install:

### Ubuntu 12.04
$ qemu-arm -L /usr/arm-linux-gnueabi /usr/arm-linux-gnueabi/lib/libc-2.15.so 
(...)
Compiled by GNU CC version 4.6.3.
Compiled on a Linux 3.2.14 system on 2012-04-17.
Available extensions:
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    Support for some architectures added on, not maintained in glibc core.
    BIND-8.2.3-T5B
libc ABIs: UNIQUE
(...)

$ file /usr/arm-linux-gnueabi/lib/libc-2.15.so 
/usr/arm-linux-gnueabi/lib/libc-2.15.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.31, stripped

### Ubuntu 14.04
$ qemu-arm -L /usr/arm-linux-gnueabi /usr/arm-linux-gnueabi/lib/libc-2.19.so 
(...)
Compiled by GNU CC version 4.8.2.
Compiled on a Linux 3.13.4 system on 2014-02-25.
Available extensions:
    crypt add-on version 2.1 by Michael Glad and others
    GNU Libidn by Simon Josefsson
    Native POSIX Threads Library by Ulrich Drepper et al
    BIND-8.2.3-T5B
libc ABIs: UNIQUE
(...)

$ file /usr/arm-linux-gnueabi/lib/libc-2.19.so 
/usr/arm-linux-gnueabi/lib/libc-2.19.so: ELF 32-bit LSB  shared object, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped

where:

  • The qemu-arm -L commands are used to determine the kernel version against which the C library was built.

  • file(1) reads the .note.ABI-tag section of an ELF Object File to determine the minimum supported kernel version by the C library1.

See GNU/Linux Toolchain Intro for a discussion of the implications of these settings.

Linaro Cross-Toolchain from Source with crosstool-NG

Crosstool New Generation (crosstool-NG) is a fork of the original crosstool toolchain build facility. Support in upstream crosstool-NG for the linaro toolchain was added shortly after the 1.10 release.

Resources

  • https://wiki.linaro.org/WorkingGroups/ToolChain
  • https://launchpad.net/~linaro-maintainers/+archive/toolchain

Footnotes

1. See src/readelf.c of file(1)'s source code. [go back]