Using build-many-glibcs.py
The GNU C Library project maintains a
script called build-many-glibcs.py
that is used, according to its source
code, to:
Build many configurations of glibc
As of today, the script allows to cross compile glibc for 93 different glibc
configurations used in the most common triplets supported by glibc.
But build-many-glibcs.py
is also useful to create 52 cross compilers
that can be used by other projects unrelated to glibc.
Downloading the source code
First you have to have the glibc source code in your computer.
In my case, I'm going to download it to ~/src/glibc
by running the following
commands:
$ cd ~/src
$ git clone https://sourceware.org/git/glibc.git
Now, we need to create a directory for the build-many-glibcs artifacts.
I'm using ~/build-many-glibs
:
$ mkdir ~/build-many-glibcs
$ cd ~/build-many-glibcs
In the following step, we ask build-many-glibcs.py
to download the source
code of all the projects it builds:
$ ~/src/glibc/scripts/build-many-glibcs.py ./ checkout
The download might take a while.
Notice this step will download the glibc
source code again and will store it under ~/build-many-glibcs/src/glibc
.
The script will build glibc using the source code it downloaded and not
from ~/src/glibc
.
Building the host libraries
In the next step, we have to build the host libraries that will be used by the cross compilers: libgmp, libmpc and libmpfr.
$ ~/src/glibc/scripts/build-many-glibcs.py -j 160 ./ host-libraries
This step is really fast, but it benefits from parallel jobs as specified
by parameter -j 160
.
Building the cross compilers
In this step, we'll build the cross compilers.
This is the first time you can list the architectures and build combinations
you'd like to build, but if you run the compilers
command without
specifying the list of compiler configurations, build-many-glibcs.py
will
build all the configurations available.
$ ~/src/glibc/scripts/build-many-glibcs.py -j 160 ./ compilers
The execution of this command will take a couple of hours and will require ~50 GiB of disk space. I suggest to save the contents of this directory for future executions.
Building glibcs
If all you need is a cross compiler, you can stop after the previous command. However, if you plan to build glibc too, there is one final command:
$ ~/src/glibc/scripts/build-many-glibcs.py -j 160 ./ glibcs
This is going to build, install and run all glibc tests available at a cross compilation for all the 93 glibc configurations. It will take many hours to complete. If you don't need all the configurations, you can list the ones that you need.