5.6. Libstdc++ de GCC-12.2.0

Libstdc++ is the standard C++ library. It is needed to compile C++ code (part of GCC is written in C++), but we had to defer its installation when we built gcc-pass1 because Libstdc++ depends on Glibc, which was not yet available in the target directory.

Temps de construction approximatif: 0.4 SBU
Espace disque requis: 1.1 Go

5.6.1. Installation de Libstdc++ Cible

[Note]

Note

Libstdc++ fait partie des sources de GCC. Vous devriez d'abord déballer l'archive tar de GCC et vous rendre dans le répertoire gcc-12.2.0.

Create a separate build directory for Libstdc++ and enter it:

mkdir -v build
cd build

Prepare Libstdc++ for compilation:

../libstdc++-v3/configure           \
    --host=$LFS_TGT                 \
    --build=$(../config.guess)      \
    --prefix=/usr                   \
    --disable-multilib              \
    --disable-nls                   \
    --disable-libstdcxx-pch         \
    --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/12.2.0

Voici la signification des options de configuration :

--host=...

Specifies that the cross-compiler we have just built should be used instead of the one in /usr/bin.

--disable-libstdcxx-pch

Ce paramètre empêche l'installation des fichiers inclus pré-compilés, qui ne sont pas nécessaires pour l'instant.

--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/12.2.0

This specifies the installation directory for include files. Because Libstdc++ is the standard C++ library for LFS, this directory should match the location where the C++ compiler ($LFS_TGT-g++) would search for the standard C++ include files. In a normal build, this information is automatically passed to the Libstdc++ configure options from the top level directory. In our case, this information must be explicitly given. The C++ compiler will prepend the sysroot path $LFS (specified when building GCC-pass1) to the include file search path, so it will actually search in $LFS/tools/$LFS_TGT/include/c++/12.2.0. The combination of the DESTDIR variable (in the make install command below) and this switch causes the headers to be installed there.

Compile Libstdc++ by running:

make

Installez la bibliothèque :

make DESTDIR=$LFS install

Remove the libtool archive files because they are harmful for cross-compilation:

rm -v $LFS/usr/lib/lib{stdc++,stdc++fs,supc++}.la

Les détails sur ce paquet sont disponibles dans Section 8.26.2, « Contenu de GCC. »