aboutsummaryrefslogtreecommitdiffstats
path: root/chapter06
diff options
context:
space:
mode:
authorXi Ruoyao <xry111@mengyan1223.wang>2022-02-27 01:09:05 +0800
committerXi Ruoyao <xry111@mengyan1223.wang>2022-02-27 23:36:55 +0800
commit459d4936aec6671d94a0a4be918d8efbbc130215 (patch)
tree7c418c9970c882b31a73fde8b58f7f5aa55478de /chapter06
parentcbd0a9a98e1fc17cf652b6db5fa223fe5b3043fa (diff)
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.
Diffstat (limited to 'chapter06')
-rw-r--r--chapter06/gcc-pass2.xml26
1 files changed, 14 insertions, 12 deletions
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</userinput></screen>
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
;;
esac</userinput></screen>
-<!--
- <para>Fix an issue with GCC-10.1 when building with a cross
- compiler:</para>
-<screen><userinput remap="pre">patch -Np1 -i ../&gcc-cross-patch;</userinput></screen>
--->
+ <!-- https://gcc.gnu.org/PR100017 -->
+ <para>Fix an issue causing failure cross-compiling libstdc++:</para>
+
+<screen><userinput remap="pre">sed 's/gnu++17/&amp; -nostdinc++/' \
+ -i libstdc++-v3/src/c++17/Makefile.in</userinput></screen>
+
+ <para>Override the building rule of libgcc and libstdc++ headers, to
+ allow building these libraries with POSIX threads support:</para>
+
+<screen><userinput remap="pre">sed '/thread_header =/s/@.*@/gthr-posix.h/' \
+ -i libgcc/Makefile.in libstdc++-v3/include/Makefile.in</userinput></screen>
+
<para>Create a separate build directory again:</para>
<screen><userinput remap="pre">mkdir -v build
cd build</userinput></screen>
- <para>Create a symlink that allows libgcc to be built with posix threads
- support:</para>
-
-<screen><userinput remap="pre">mkdir -pv $LFS_TGT/libgcc
-ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></screen>
-
<para>Before starting to build GCC, remember to unset any environment
variables that override the default optimization flags.</para>
@@ -89,6 +90,8 @@ ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></s
--host=$LFS_TGT \
--prefix=/usr \
CC_FOR_TARGET=$LFS_TGT-gcc \
+ CXX_FOR_TARGET=$LFS_TGT-g++ \
+ LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
--with-build-sysroot=$LFS \
--enable-initfini-array \
--disable-nls \
@@ -99,7 +102,6 @@ ln -s ../../../libgcc/gthr-posix.h $LFS_TGT/libgcc/gthr-default.h</userinput></s
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
- --disable-libstdcxx \
--enable-languages=c,c++</userinput></screen>
<variablelist>