v. About the Multilib Edition

What is Multilib

Today, most systems in the x86 world have a word size of 64 bit. The word size is a number of bits which can be used at once in the most efficient way. Previous architectures of x86 processors had a word size of 32 bit which means they have a different understanding of what is the best alignment of data in memory as well as they have a different mechanism to address a different size of memory. Even the instruction set of the 64 bit processors is quite simmilar to the instructions of 32 bit processors, binaries (objects compiled to machine code) cannot directly be executed on 64 bit systems.

Multilib is a mechanism to provide support for the 32 bit binaries so that they can be executed of modern 64 bit CPUs.

Why doing Multilib?

From a educational point of view, LFS in its 'native' form is probably the best way to see how a Linux system is built from source. There is no need to confuse with different architectures. But when there is a need to run 32 binaries and you don't want to build the whole system in 32 bit (which would be waste of ressources nowadays) than LFS-multilib is an option. Examples for such a need could be

  • Closed-source software without source only available for 32 bit. That may be the case for printer driver or any other kind of hardware drivers, the company provides the binaries. If you have such a driver, LFS-multilib may help you getting the stuff running

  • If you want to go far beyond LFS and setup a virtualization platform like VirtualBox, you will need multilib support

  • or even just because you can

The multilib edition of LFS goes a small step beyond and a small step back to what has been said in the previous section when talking about target architectures. On one hand, the multilib edition is focused and limited to x86_64 architectures only, on the other hand, it expands the instructions to utilize both possible architectures, namely 32-bit as well as 64-bit.

It also goes a bit beyond the basic educational approach of LFS which is to show you how to build a Linux system. To achieve this, no support for additional architectures than the default one for your system is required. If you haven't previously built by the standard LFS book, you are encouraged to do so before using this edition.

Building a Multilib System

Building a multilib system is not that much different from building a system by using the 'native' LFS book. Beside some tweaks here and there the most prominent difference is that multilib requires compiling some applications up to three times: one for the primary 64-bit architecture, one for the 32-bit architecture (m32), and once again for the 32-bit architecture with is 32-bit memory access and 64 bit instruction set (mx32).

Continue only if you and your system meets the following requirements:

  • you have a x86_64 compatible machine



    If you have access to the kernel config for your system, you will need to have CONFIG_IA32_EMULATION=y set in order to build for m32 and CONFIG_X86_X32=y set in order to build for mx32.

    If you do not have access to the kernel config for your system, you may be able to test for compatability by running the following commands:

    echo 'int main(){}' > dummy.c
    gcc -m32 dummy.c
    gcc -mx32 dummy.c

    If either of the ./a.out commands results in an "Exec format error" message, then you do not have a system kernel capable of building for that architecture within LFS, and so you should probably look to build an LFS system without Multilib, but with the required kernel capabilities, and use that to build a Multilib system.

  • you already have some experience with LFS

  • you have a need for 32-bit support

If you passed all three requirements, go ahead and build LFS in multilib mode.