arm-none-eabi toolchain compile from source

Viewed 564

For my current project we are having an issue which we can solve if we are able to recompile the arm toolchain (gcc, c++stdlib, nanolibc, etc) from source.

From the arm website I can download a snapshot of the source. I found a blog but it's outdated. The pdf he refers to no longer exists in this snapshot anyway.

Browsing through the extracted archive I can't seem to find any instructions how to compile.

Where can I find documentation how to compile arm-none-eabi from source?

2 Answers

The release notes available at the download site include build-from-source instructions.

I've made a quick transcription here, but future readers should be warned it may have become out-of-date.

How to build the toolchain from sources

You can build Arm GNU Toolchain from sources using Linaro ABE (Advanced Build Environment) and provided ABE manifest files.

Below example shows how to build gcc-arm-aarch64-none-elf toolchain from sources using Linaro ABE build system.

Instructions

ABE has a dependency on git-new-workdir and needs this tool to be installed in /usr/local/bin directory:

$ wget https://raw.githubusercontent.com/git/git/master/contrib/workdir/git-new-workdir
$ sudo mv git-new-workdir /usr/local/bin
$ sudo chmod +x /usr/local/bin/git-new-workdir 

Clone ABE from the URL below and checkout the stablebranch (see Getting ABE):

$ git clone https://git.linaro.org/toolchain/abe.git

Create the build directory and change to it. Any name for the directory will work:

$ mkdir build && cd build

Configure ABE (from the build directory):

$ ../abe/configure

Download the toolchain manifest file, from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/downloads, into the build folder, for the required toolchain, for example, gcc-arm-aarch64-none-elf-abe-manifest.txt:

$  wget https://developer.arm.com/-/media/Files/downloads/gnu/11.2-2022.02/manifest/gcc-arm-aarch64-none-elf-abe-manifest.txt

Build toolchain (from the build directory):

$ ../abe/abe.sh --manifest gcc-arm-aarch64-none-elf-abe-manifest.txt --build all

The built toolchain will be installed and available for use in the builds/destdir/x86_64-unknown-linux-gnu/bin/ directory.

# Usage
# sudo ./build_arm

# Setup vars
export TARGET=arm-none-eabi
export PREFIX=/opt/gnuarm
export PATH=$PATH:$PREFIX/bin
export JN='-j 8'

export GCCVER=11.2.0
export BINUVER=2.37

rm -rf build-*
rm -rf gcc-*
rm -rf binutils-*

# Get archives
wget https://ftp.gnu.org/gnu/binutils/binutils-$BINUVER.tar.gz
wget https://ftp.gnu.org/gnu/gcc/gcc-$GCCVER/gcc-$GCCVER.tar.gz

# Extract archives
tar xf binutils-$BINUVER.tar.gz
tar xf gcc-$GCCVER.tar.gz

# Build binutils
mkdir build-binutils
cd build-binutils
../binutils-$BINUVER/configure --target=$TARGET --prefix=$PREFIX
echo "MAKEINFO = :" >> Makefile
make $JN all
sudo make install

# Build GCC
mkdir ../build-gcc
cd ../build-gcc
../gcc-$GCCVER/configure --target=$TARGET --prefix=$PREFIX --without-headers --with-newlib  --with-gnu-as --with-gnu-ld --enable-languages='c' --enable-frame-pointer=no
make $JN all-gcc
sudo make install-gcc

# Build libgcc.a
make $JN all-target-libgcc CFLAGS_FOR_TARGET="-g -O2"
sudo make install-target-libgcc
Related