Prerequisites
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)
1 | archives/ |
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.
1 | cd toolchain/sources/binutils-2.23.2 |
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.
1 | cd build/binutils |
GCC - First stage
We’re gonna compile GCC and musl in multiple stages. First we’re gonna compile the GCC compiler.
1 | cd build/gcc |
Kernel headers
We need the kernel headers for the next steps so enter the kernel folder and install them.
1 | sudo make ARCH=mips INSTALL_HDR_PATH=/opt/cross/mips64-octeon-linux-musl/ headers_install |
musl - First stage
Here we’re building some objects required by libgcc in the next step.
1 | cd build/musl |
GCC - Second stage
Now that we have bootstrapped musl, we can compile and install libgcc for the target.
1 | cd build/gcc |
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.
1 | cd build/musl |
GCC - Third stage
Lastly we’ll compile the C++ standard library in GCC and install it.
1 | cd build/gcc |
If you’ve done everything correctly, you should now have a musl toolchain for the Octeon architecture.