mar 11, 2022

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.

set 08, 2021

The Moon

The Moon

set 07, 2021

Quote of the day

O que antes era marketing massivo, agora é personalização massiva. As marcas que mais rapidamente entenderem isso, vão se sobressair. É uma corrida em que a tecnologia te ajuda a entender melhor o cliente e suas nuances. - Paulo Camargo

ago 25, 2021

Migrating to Pelican

After a long time, I've finally complete the migration of this site to Pelican.

In the end, I decided to remove old posts that had no value anymore and converted the remaining to the new format. Hopefully, this will help me write more. :-D

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
Next → Page 1 of 3