mar 11, 2022


The GNU C Library project maintains a script called 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 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

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 to download the source code of all the projects it builds:

$ ~/src/glibc/scripts/ ./ 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/ -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, will build all the configurations available.

$ ~/src/glibc/scripts/ -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/ -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.

jan 23, 2019

Reading the serial number of a POWER server from Linux

From time to time, I have to identify which physical server I'm connected to. That usually involves reading the manufacturer serial number of the server. That information is provided to Linux by the device tree, which is exported via procfs at /proc/device-tree/.

However, the file that hosts the serial number of your server may vary according to the virtualization mechanism in place, e.g. bare-metal and LPARs use the file system-id, while KVM guests use the file host-serial.

With that said, we can read the serial number of our server with the following command:

find /proc/device-tree/ -name host-serial -o -name system-id | xargs cat; echo