Hi,
As the next gcc version will use a C++ compiler, I thought I could
try to test the possibility of building gcc-4.7.2 with g++. There is a
configure switch for that: --enable-build-with-cxx.
If you wonder why I did not try gcc-4.8 snapshots in the first place,
the reason is that sometimes snapshots are broken. The first one
I picked (gcc-4.8-20121230) could not bootstrap itself. But I believed
for a long while that it was my building instructions, which caused the
failure. So I went back to a surely working version.
Of course, as already said on the list, there is a chicken and egg problem
here, since gcc will need g++ and its library libstdc++ for being
compiled, but libstdc++ needs glibc, which is not available at the
beginning of the build.
I have tried two solutions, which both seem to give good results:
1)
- First build glibc with the host tools (of course you have to unpack
the kernel headers first), that is removing the --host --build switches
from configure invocation. The build machinery is strong
enough to build libraries which are insulated from those on the
host. The only thing which may happen is that configure takes
wrong decisions, based on what is on the host. This method
is thus distro-dependent. OTH, I think that the distro should
not matter much if it is recent enough (less than 3-4 years say).
The /tools/lib64 has to be present when doing make install, other-
wise, the ld-linux-x86-64.so helper file is not installed...
- Then build cross binutils, cross gcc (enabling c++),
binutils-pass2 and gcc-pass2 (adding CXX=$LFS_TGT-g++),
with instructions as in the book.
2)
- Build binutils-pass1 as in the book.
- Build gcc-pass1 with --enable-languages=c,c++
and --disable-stdc++-v3. Thus we have a C++ compiler, and no library.
_Do not remove the build tree when done_.
- Build glibc as per book instructions. It uses only the C compiler and
the static libgcc as usual
- Build libstdc++-v3: create a directory libstdc++-v3 in
gcc-build/$LFS_TGT,
change to that dir, run ../../../gcc-<version>/libstdc++-v3 configure (see
attached patch). then make and make install, "et voila".
- Finish with binutils-pass2 and gcc-pass2 (adding CXX=$LFS_TGT-g++ as
above).
Comparing methods 1 and 2. The 1 is simpler, and does not have the "keep
build dir around" trick. It might fail on some distros and needs being
tested
on several ones. The 2 might be cleaner, but it needs having both
gcc and glibc build dirs on disk at the same time (well disk space is cheap
nowdays...). It uses undocumented behavior, which can be broken by
upstream at any time (hopefully not too often). I have been able to build
all BLFS packages up to a running KDE with both methods.
Sorry for this long message. Wanted to share.
Regards,
Pierre
Index: chapter05/binutils-pass2.xml
===================================================================
--- chapter05/binutils-pass2.xml (révision 10092)
+++ chapter05/binutils-pass2.xml (copie de travail)
@@ -56,6 +56,7 @@
../binutils-&binutils-version;/configure \
--prefix=/tools \
--disable-nls \
+ --with-sysroot \
--with-lib-path=/tools/lib</userinput></screen>
<variablelist>
Index: chapter05/chapter05.xml
===================================================================
--- chapter05/chapter05.xml (révision 10092)
+++ chapter05/chapter05.xml (copie de travail)
@@ -18,6 +18,7 @@
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass1.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="linux-headers.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="glibc.xml"/>
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="libstdc++.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
href="binutils-pass2.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="gcc-pass2.xml"/>
<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="tcl.xml"/>
Index: chapter05/libstdc++.xml
===================================================================
--- chapter05/libstdc++.xml (révision 0)
+++ chapter05/libstdc++.xml (copie de travail)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
+ <!ENTITY % general-entities SYSTEM "../general.ent">
+ %general-entities;
+]>
+
+<sect1 id="ch-tools-libstdcpp" role="wrap">
+ <?dbhtml filename="libstdc++.html"?>
+
+ <sect1info condition="script">
+ <productname>gcc</productname>
+ <productnumber>&gcc-version;</productnumber>
+ <address>&gcc-url;</address>
+ </sect1info>
+
+ <title>libstdc++-&gcc-version;</title>
+
+ <indexterm zone="ch-tools-libstdcpp">
+ <primary sortas="a-GCC">GCC</primary>
+ <secondary>tools, libstdc++</secondary>
+ </indexterm>
+
+ <sect2 role="package">
+ <title/>
+
+ <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
+ href="../chapter06/gcc.xml"
+ xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
+
+ <segmentedlist>
+ <segtitle>&buildtime;</segtitle>
+ <segtitle>&diskspace;</segtitle>
+
+ <seglistitem>
+ <seg>&gcc-ch5p1-sbu;</seg>
+ <seg>&gcc-ch5p1-du;</seg>
+ </seglistitem>
+ </segmentedlist>
+
+ </sect2>
+
+ <sect2 role="installation">
+ <title>Installation of Target Libstdc++</title>
+
+ <note>
+ <para>We have kept the build directories from the first pass of GCC.
+ You should start from the GCC source directory
+ <filename>gcc-&gcc-version;</filename>
+ </para>
+ </note>
+ <para>Create a directory for Libstdc++ in the
+ <filename>gcc-build</filename> hierarchy and enter it:</para>
+
+<screen><userinput remap="pre">mkdir -v ../gcc-build/$LFS_TGT/libstdc++-v3
+cd ../gcc-build/$LFS_TGT/libstdc++-v3</userinput></screen>
+
+ <para>Prepare Libstdc++ for compilation:</para>
+
+<screen><userinput
remap="configure">../../../gcc-&gcc-version;/libstdc++-v3/configure \
+ --host=$LFS_TGT \
+ --prefix=/tools \
+ --disable-multilib \
+ --disable-shared \
+ --disable-nls \
+ --disable-libstdcxx-threads \
+ --disable-libstdcxx-pch \
+
--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/&gcc-version;</userinput></screen>
+
+ <variablelist>
+ <title>The meaning of the configure options:</title>
+
+ <varlistentry>
+ <term><parameter>--host=...</parameter></term>
+ <listitem>
+ <para>Indicates to use the cross compiler we have just built
+ instead of the one in <filename>/usr/bin</filename>.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><parameter>--disable-libstdcxx-threads</parameter></term>
+ <listitem>
+ <para>Since we have not built the thread C library, the C++
+ one cannot be built as well.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><parameter>--disable-libstdcxx-pch</parameter></term>
+ <listitem>
+ <para>This switch prevent the installation of precompiled
+ include files, which are not needed at this stage.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+
<term><parameter>--with-gxx-include-dir=/tools/include/c++/&gcc-version;</parameter></term>
+ <listitem>
+ <para>This is the location where the standard include files are
+ searched by the C++ compiler. In a normal build, this information
+ is automatically passed to the Libstdc++ <command>configure</command>
+ options from the toplevel directory. In our case, this information
+ has been lost.</para>
+ </listitem>
+ </varlistentry>
+
+ </variablelist>
+
+ <para>Compile libstdc++ by running:</para>
+
+<screen><userinput remap="make">make</userinput></screen>
+
+ <para>Install the library:</para>
+
+<screen><userinput remap="install">make install</userinput></screen>
+
+ </sect2>
+
+ <sect2 role="content">
+ <title/>
+
+ <para>Details on this package are located in
+ <xref linkend="contents-gcc" role="."/></para>
+
+ </sect2>
+
+</sect1>
Index: chapter05/gcc-pass1.xml
===================================================================
--- chapter05/gcc-pass1.xml (révision 10092)
+++ chapter05/gcc-pass1.xml (copie de travail)
@@ -130,7 +130,12 @@
--disable-libssp \
--disable-libgomp \
--disable-libquadmath \
- --enable-languages=c \
+ --disable-libatomic \
+ --disable-libitm \
+ --disable-libsanitizer \
+ --disable-libstdc++-v3 \
+ --enable-languages=c,c++ \
+ --enable-build-with-cxx \
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>
@@ -188,10 +193,11 @@
</varlistentry>
<varlistentry>
- <term><parameter>--disable-decimal-float, --disable-threads,
--disable-libmudflap, --disable-libssp, --disable-libgomp,
--disable-libquadmath</parameter></term>
+ <term><parameter>--disable-decimal-float, --disable-threads,
--disable-libmudflap, --disable-libssp, --disable-libgomp,
--disable-libquadmath, --disable-libatomic, --disable-libitm,
--disable-libsanitizer</parameter></term>
<listitem>
<para>These switches disable support for the decimal floating point
- extension, threading, libmudflap, libssp and libgomp and libquadmath
+ extension, threading, libmudflap, libssp, libgomp, libquadmath,
+ libatomic, libitm and libsanitizer
respectively. These features will fail to compile when building a
cross-compiler and are not necessary for the task of cross-compiling
the temporary libc.</para>
@@ -199,6 +205,16 @@
</varlistentry>
<varlistentry>
+ <term><parameter>--disable-libstdc++-v3</parameter></term>
+ <listitem>
+ <para>The libstdc++ library is needed by the C++ compiler. However,
+ it cannot be compiled without glibc support. Unfortunately, glibc
+ is not yet built. This switch disables its compilation for now.
+ It will have to be built after glibc.</para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><parameter>--disable-multilib</parameter></term>
<listitem>
<para>On x86_64, LFS does not yet support a multilib configuration.
@@ -240,6 +256,10 @@
<screen><userinput remap="install">ln -sv libgcc.a `$LFS_TGT-gcc
-print-libgcc-file-name | sed 's/libgcc/&_eh/'`</userinput></screen>
+ <note>
+ <para>The build environment is needed for the later installation of
+ Libstdc++. So do not remove the build directories.</para>
+ </note>
</sect2>
<sect2 role="content">
Index: chapter05/gcc-pass2.xml
===================================================================
--- chapter05/gcc-pass2.xml (révision 10092)
+++ chapter05/gcc-pass2.xml (copie de travail)
@@ -107,7 +107,8 @@
<para>Now prepare GCC for compilation:</para>
-<screen><userinput remap="configure">CC=$LFS_TGT-gcc \
+<screen><userinput remap="configure">CC=$LFS_TGT-gcc \
+CXX=$LFS_TGT-g++ \
AR=$LFS_TGT-ar \
RANLIB=$LFS_TGT-ranlib \
../gcc-&gcc-version;/configure \
@@ -123,6 +124,7 @@
--disable-multilib \
--disable-bootstrap \
--disable-libgomp \
+ --enable-build-with-cxx \
--with-mpfr-include=$(pwd)/../gcc-&gcc-version;/mpfr/src \
--with-mpfr-lib=$(pwd)/mpfr/src/.libs</userinput></screen>
Index: chapter06/gcc.xml
===================================================================
--- chapter06/gcc.xml (révision 10092)
+++ chapter06/gcc.xml (copie de travail)
@@ -78,6 +78,7 @@
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
+ --enable-build-with-cxx \
--with-system-zlib</userinput></screen>
<para>Note that for other languages, there are some prerequisites that
--
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page