[lfs] 02/04: gcc-pass2: add CXX_FOR_TARGET="$LFS_TGT-gcc -nostdinc++"

git Owner ([email protected] via lfs-book Mailing List) <[email protected]> Fri, 31 Jul 2026 20:14:14 +0000
Newsgroups gmane.linux.lfs.book
Message-ID <[email protected]>
This is a multi-part message in MIME format...

------------=_1785528865-3417499-7024
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch trunk
in repository lfs.

commit 47f35a8df3131d4b13cc00508f6c79b860ef105e
Author: Xi Ruoyao <[email protected]>
AuthorDate: Tue Jul 28 21:53:05 2026 +0800

    gcc-pass2: add CXX_FOR_TARGET="$LFS_TGT-gcc -nostdinc++"
    
    In gcc-pass2 the C++ std module fails to build, similar to the issue
    we've fixed for gcc-pass1 at commit 2be87ced88fc.  Here it's even more
    complicated than gcc-pass1: the problem is the libstdc++ fenv.h
    has #include_next <fenv.h> and expects the directive to find glibc
    fenv.h, but with CXX_FOR_TARGET=$LFS_TGT-g++ (the default) the compiler
    finds it's own (installed at ch.05 libstdc++) fenv.h, then
    this #include_next directive finds fenv.h in the gcc-pass2 build, and
    because of the _GLIBCXX_FENV_H include guard gcc-pass2 fenv.h won't pull
    the glibc header anymore.  Then the build will report errors like
    "cannot find fenv_t" etc.
    
    To resolve the issue, pass CXX_FOR_TARGET="$LFS_TGT-gcc -nostdinc++"
    like what the top-level build system does for a native build.
---
 chapter06/gcc-pass2.xml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/chapter06/gcc-pass2.xml b/chapter06/gcc-pass2.xml
index 9f7d49d82..0d579311a 100644
--- a/chapter06/gcc-pass2.xml
+++ b/chapter06/gcc-pass2.xml
@@ -91,6 +91,7 @@ cd       build</userinput></screen>
     --disable-libssp           \
     --disable-libvtv           \
     --enable-languages=c,c++   \
+    CXX_FOR_TARGET="$LFS_TGT-gcc -nostdinc++" \
     LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
     target_configargs=gcc_cv_target_thread_file=posix</userinput></screen>
 
@@ -148,6 +149,21 @@ cd       build</userinput></screen>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><parameter>CXX="$LFS_TGT-gcc -nostdinc++"</parameter></term>
+        <listitem>
+          <para>Specifies to use <command>$LFS_TGT-gcc</command> to compile
+          the C++ code like <xref linkend='ch-tools-libstdcpp'/> and prevent
+          the compiler from using the headers from the previous libstdc++
+          installation.  Mixing those headers and the C++ headers from the
+          current libstdc++ build can cause the
+          <literal>#include_next</literal> directives fail to find the C
+          headers.  In a normal build, this override is automatically passed
+          to the <command>configure</command> script from the top level
+          directory.  Here we explicitly pass it.</para>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><parameter>LDFLAGS_FOR_TARGET=...</parameter></term>
         <listitem>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

------------=_1785528865-3417499-7024
Content-Type: text/plain; charset="UTF-8"
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0

-- 
http://lists.linuxfromscratch.org/sympa/info/lfs-book
Unsubscribe: See the above information page

------------=_1785528865-3417499-7024--