Building an Octeon toolchain

Folder structure

Download the source archives into the archives folder. Extract the Cavium patchset archive into the toolchain/patches folder, the rest goes into the toolchain/sources folder.
You need to create symlinks in the GCC source folder to the it’s various dependencies as shown below.

You also need to create build/ folders for each of the components we’re building (Binutils, GCC, Musl)

Compiling Binutils

First we need to apply (most) of Caviums patches. Preferably we’d apply them all, but there seems to be some overlap in their patches so after 0112 patching failes. However the necessary patches for the Octeon platform works, so I didn’t take the time to look more into this.

We also need a patch from GregorR’s repo that enables the musl target for older Binutils versions.

Now we can compile and install Binutils. Be aware that I’m using nproc in the make command to determine how many processors are available. If you don’t have coreutils installed you should specify the amount of jobs you want to run manually.

GCC - First stage

We’re gonna compile GCC and musl in multiple stages. First we’re gonna compile the GCC compiler.

We need the kernel headers for the next steps so enter the kernel folder and install them.

musl - First stage

Here we’re building some objects required by libgcc in the next step.

GCC - Second stage

Now that we have bootstrapped musl, we can compile and install libgcc for the target.

musl - Second stage

With libgcc installed we can finish off musl. Note that we have to run the ./configure script again to detect the location of libgcc.

GCC - Third stage

Lastly we’ll compile the C++ standard library in GCC and install it.

If you’ve done everything correctly, you should now have a musl toolchain for the Octeon architecture.