From 459d4936aec6671d94a0a4be918d8efbbc130215 Mon Sep 17 00:00:00 2001 From: Xi Ruoyao Date: Sun, 27 Feb 2022 01:09:05 +0800 Subject: [PATCH] fix GCC PR100017 and enable libstdc++ for pass 2 This is the issue preventing us from cross-compiling libstdc++ in Chapter 6. By fixing this issue we can remove a seperate pass 2 for libstdc++ and simplify the instruction. The upstream fix will be released in 11.3 and 12.0, so we can remove the first sed upgrading gcc next time. --- chapter05/libstdc++.xml | 8 +-- chapter06/gcc-pass2.xml | 26 ++++---- chapter07/chapter07.xml | 1 - chapter07/libstdc++-pass2.xml | 120 ---------------------------------- 4 files changed, 18 insertions(+), 137 deletions(-) delete mode 100644 chapter07/libstdc++-pass2.xml diff --git a/chapter05/libstdc++.xml b/chapter05/libstdc++.xml index 5a70026ed..66f17fcd8 100644 --- a/chapter05/libstdc++.xml +++ b/chapter05/libstdc++.xml @@ -5,8 +5,8 @@ %general-entities; ]> - - + + gcc-libstdc++ @@ -14,9 +14,9 @@
&gcc-url;
- Libstdc++ from GCC-&gcc-version;, Pass 1 + Libstdc++ from GCC-&gcc-version; - + GCC tools, libstdc++ pass 1 diff --git a/chapter06/gcc-pass2.xml b/chapter06/gcc-pass2.xml index bf3007848..6dd6f90a5 100644 --- a/chapter06/gcc-pass2.xml +++ b/chapter06/gcc-pass2.xml @@ -62,23 +62,24 @@ mv -v mpc-&mpc-version; mpc sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64 ;; esac - + + Fix an issue causing failure cross-compiling libstdc++: + +sed 's/gnu++17/& -nostdinc++/' \ + -i libstdc++-v3/src/c++17/Makefile.in + + Override the building rule of libgcc and libstdc++ headers, to + allow building these libraries with POSIX threads support: + +sed '/thread_header =/s/@.*@/gthr-posix.h/' \ + -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in + Create a separate build directory again: mkdir -v build cd build - Create a symlink that allows libgcc to be built with posix threads - support: - -mkdir -pv $LFS_TGT/libgcc -ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h - Before starting to build GCC, remember to unset any environment variables that override the default optimization flags. @@ -89,6 +90,8 @@ ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h diff --git a/chapter07/chapter07.xml b/chapter07/chapter07.xml index 8c78f230a..362980dda 100644 --- a/chapter07/chapter07.xml +++ b/chapter07/chapter07.xml @@ -17,7 +17,6 @@ - diff --git a/chapter07/libstdc++-pass2.xml b/chapter07/libstdc++-pass2.xml deleted file mode 100644 index 35b5a8baf..000000000 --- a/chapter07/libstdc++-pass2.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - %general-entities; -]> - - - - - - gcc-libstdc++ - &gcc-version; -
&gcc-url;
-
- - Libstdc++ from GCC-&gcc-version;, Pass 2 - - - GCC - tools, libstdc++ pass 2 - - - - - - <para>When building <xref linkend="ch-tools-gcc-pass2"/> we had to defer - the installation of the C++ standard library because no suitable compiler - was available to compile it. We could not use the compiler built in that - section because it is a native compiler and should not be used outside of - chroot and risks polluting the libraries with some host components.</para> - - <segmentedlist> - <segtitle>&buildtime;</segtitle> - <segtitle>&diskspace;</segtitle> - - <seglistitem> - <seg>&libstdcpp-tmpp2-sbu;</seg> - <seg>&libstdcpp-tmpp2-du;</seg> - </seglistitem> - </segmentedlist> - - </sect2> - - <sect2 role="installation"> - <title>Installation of Target Libstdc++ - - - Libstdc++ is part of the GCC sources. - You should first unpack the GCC tarball and change to the - gcc-&gcc-version; directory. - - - Create a link which exists when building libstdc++ in the gcc tree: - -ln -s gthr-posix.h libgcc/gthr-default.h - - Create a separate build directory for libstdc++ and enter it: - -mkdir -v build -cd build - - Prepare libstdc++ for compilation: - -../libstdc++-v3/configure \ - CXXFLAGS="-g -O2 -D_GNU_SOURCE" \ - --prefix=/usr \ - --disable-multilib \ - --disable-nls \ - --host=$(uname -m)-lfs-linux-gnu \ - --disable-libstdcxx-pch - - - The meaning of the configure options: - - - CXXFLAGS="-g -O2 -D_GNU_SOURCE" - - These flags are passed by the top level Makefile when doing - a full build of GCC. - - - - - --host=$(uname -m)-lfs-linux-gnu - - We have to mimic what would happen if this package were built - as part of a full compiler build. This switch would be passed to - configure by GCC's build machinery. - - - - - --disable-libstdcxx-pch - - This switch prevents the installation of precompiled - include files, which are not needed at this stage. - - - - - - Compile libstdc++ by running: - -make - - Install the library: - -make install - - - - - - - <para>Details on this package are located in <xref linkend="contents-gcc" role="."/></para> - - </sect2> - -</sect1>