User:Immolo/RPIzero

This guide will build a clang and musl Gentoo system for a 32bit ARM device like the RPI Zero W. This is only tested as working with ~arm so this process is intended for users that have used Gentoo for some time.

Prerequisite
Using the Embedded Handbook/General/Compiling with qemu user chroot page as template, the user should have the latest stage3-armv6j_hardfp-musl-openrc ready to build the image on a faster machine.

Configs
Set the chroot up as a normal install for Gentoo would go:

Below is how make.conf should look for the first build of llvm/clang:

Adding a  value for the number of jobs the computer can build for can also be added at this stage but no other optimizations should be set now.

First build with GCC
GCC needs to compile llvm/clang but this causes some issues with compiling future programs so this workaround is needed.

Second build
Now clang can rebuild itself by following these steps:

Rebuild @world
Now llvm/clang is setup then Gentoo can be configured for the desired device, in the case of this example a Raspberry Pi Zero W is the target so it will be optimized for low RAM usage with  and Link Time Optimization will be used. The person following this can change to the needs of the targeted system.

Finally, use  to begin rebuilding every package on the system: