source: chapter05/gcc-pass2.xml@ d1e22ae

Last change on this file since d1e22ae was 06fbd5b, checked in by Jeremy Huntwork <jhuntwork@…>, 19 years ago

Added sed to chapter 5 gcc builds to force the fixincludes to use headers from /tools and not the host.

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/gcc4/BOOK@6544 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 7.7 KB
RevLine 
[673b0d8]1<?xml version="1.0" encoding="ISO-8859-1"?>
[1770019]2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
[673b0d8]3 <!ENTITY % general-entities SYSTEM "../general.ent">
[3e36a78]4 <!ENTITY % patches-entities SYSTEM "../patches.ent">
[673b0d8]5 %general-entities;
[3e36a78]6 %patches-entities;
[673b0d8]7]>
[9652249]8<sect1 id="ch-tools-gcc-pass2" role="wrap">
[673b0d8]9<title>GCC-&gcc-version; - Pass 2</title>
10<?dbhtml filename="gcc-pass2.html"?>
[bc82645e]11
[81fd230]12<indexterm zone="ch-tools-gcc-pass2">
13<primary sortas="a-GCC">GCC</primary>
14<secondary>tools, pass 2</secondary></indexterm>
15
[9652249]16<sect2 role="package"><title/>
[73aedd1d]17
[9652249]18<segmentedlist>
19<segtitle>&buildtime;</segtitle>
20<segtitle>&diskspace;</segtitle>
[fad7667]21<seglistitem><seg>11.0 SBU</seg><seg>292 MB</seg></seglistitem>
[9652249]22</segmentedlist>
[73aedd1d]23
[81fd230]24<xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
25
[9652249]26</sect2>
27
28<sect2 role="installation">
[73aedd1d]29<title>Re-installation of GCC</title>
30
[81fd230]31<para>This package is known to have issues when its default
32optimization flags (including the <parameter>-march</parameter> and
33<parameter>-mcpu</parameter> options) are changed. If any environment
34variables that override default optimizations have been defined, such
35as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
36unset them when building GCC.</para>
37
38<para>The tools required to test GCC and Binutils&mdash;Tcl, Expect
39and DejaGNU&mdash;are installed now. GCC and Binutils can now be
40rebuilt, linking them against the new Glibc and testing them properly
41(if running the test suites in this chapter). Please note that these
42test suites are highly dependent on properly functioning PTYs which
43are provided by the host. PTYs are most commonly implemented via the
44<systemitem class="filesystem">devpts</systemitem> file system. Check
45to see if the host system is set up correctly in this regard by
46performing a quick test:</para>
[73aedd1d]47
48<screen><userinput>expect -c "spawn ls"</userinput></screen>
49
[81fd230]50<para>The response might be:</para>
51
52<screen><computeroutput>The system has no more ptys.
53Ask your system administrator to create more.</computeroutput></screen>
54
[9041d47]55<para>If the above message is received, the host does not have its PTYs set up
56properly. In this case, there is no point in running the test suites for GCC and
57Binutils until this issue is resolved. Please consult the LFS FAQ at <ulink
58url="&lfs-root;/lfs/faq.html#no-ptys"/> for more information on how to get PTYs
59working.</para>
[81fd230]60
[06fbd5b]61<para>The following command adjusts where the gcc fixincludes search for headers
62so that it fixes only the new headers under /tools, not the ones from your host system.</para>
63
64<screen><userinput>sed -i 's@\(^NATIVE_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g' \
65 gcc/Makefile.in</userinput></screen>
66
[ccc95be]67<para>Make an essential adjustment:</para>
68
69<screen><userinput>patch -Np1 -i ../&gcc-specs-patch;</userinput></screen>
70
71<para>The above patch changes GCC's default location of the dynamic
[81fd230]72linker (typically <filename class="libraryfile">ld-linux.so.2</filename>). It also removes
73<filename class="directory">/usr/include</filename> from GCC's include
74search path. Patching now rather than adjusting the specs file after
75installation ensures that the new dynamic linker is used during the
76actual build of GCC. That is, all of the final (and temporary)
77binaries created during the build will link against the new
78Glibc.</para>
79
[ccc95be]80<important><para>The above patch is critical in ensuring a
[81fd230]81successful overall build. Do not forget to apply
[ccc95be]82it.</para></important>
[81fd230]83
[73aedd1d]84<para>Create a separate build directory again:</para>
85
86<screen><userinput>mkdir ../gcc-build
87cd ../gcc-build</userinput></screen>
88
[81fd230]89<para>Before starting to build GCC, remember to unset any environment
90variables that override the default optimization flags.</para>
91
[d27a27b]92<para>Now prepare GCC for compilation:</para>
[73aedd1d]93
[673b0d8]94<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
[9dfc02f]95 --libexecdir=/tools/lib --with-local-prefix=/tools \
[d72e04a]96 --enable-clocale=gnu --enable-shared \
97 --enable-threads=posix --enable-__cxa_atexit \
98 --enable-languages=c,c++ --disable-libstdcxx-pch</userinput></screen>
[73aedd1d]99
[81fd230]100<para>The meaning of the new configure options:</para>
101
102<variablelist>
103<varlistentry>
104<term><parameter>--enable-clocale=gnu</parameter></term>
105<listitem><para>This option ensures the correct locale model is
106selected for the C++ libraries under all circumstances. If the
107configure script finds the <emphasis>de_DE</emphasis> locale installed, it will select the
108correct gnu locale model. However, if the <emphasis>de_DE</emphasis> locale is not
109installed, there is the risk of building Application Binary Interface
110(ABI)-incompatible C++ libraries because the incorrect generic locale
111model may be selected.</para></listitem>
112</varlistentry>
113
114<varlistentry>
115<term><parameter>--enable-threads=posix</parameter></term>
116<listitem><para>This enables C++ exception handling for multi-threaded
117code.</para></listitem>
118</varlistentry>
119
120<varlistentry>
121<term><parameter>--enable-__cxa_atexit</parameter></term>
122<listitem><para>This option allows use of
123<emphasis>__cxa_atexit</emphasis>, rather than
124<emphasis>atexit</emphasis>, to register C++ destructors for local
125statics and global objects. This option is essential for fully
[9310805]126standards-compliant handling of destructors. It also affects the C++
[81fd230]127ABI, and therefore results in C++ shared libraries and C++ programs
128that are interoperable with other Linux
129distributions.</para></listitem>
130</varlistentry>
131
132<varlistentry>
133<term><parameter>--enable-languages=c,c++</parameter></term>
134<listitem><para>This option
135ensures that both the C and C++ compilers are built.</para></listitem>
136</varlistentry>
137
138<varlistentry>
139<term><parameter>--disable-libstdcxx-pch</parameter></term>
140<listitem><para>Do not build the pre-compiled header (PCH) for
141<filename class="libraryfile">libstdc++</filename>. It takes up a lot of space,
142and we have no use for it.</para></listitem>
143</varlistentry>
144</variablelist>
145
[73aedd1d]146<para>Compile the package:</para>
147
148<screen><userinput>make</userinput></screen>
149
[81fd230]150<para>There is no need to use the <parameter>bootstrap</parameter>
151target now because the compiler being used to compile this GCC was
152built from the exact same version of the GCC sources used
153earlier.</para>
154
155<para>Compilation is now complete. As previously mentioned, running
156the test suites for the temporary tools compiled in this chapter is
157not mandatory. To run the GCC test suite anyway, use the following
158command:</para>
[3d36131c]159
[73aedd1d]160<screen><userinput>make -k check</userinput></screen>
161
[81fd230]162<para>The <parameter>-k</parameter> flag is used to make the test suite run
163through to completion and not stop at the first failure. The GCC test
164suite is very comprehensive and is almost guaranteed to generate a few
165failures. To receive a summary of the test suite results, run:</para>
[73aedd1d]166
[673b0d8]167<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
[e8692c5e]168
[fba1478]169<para>For only the summaries, pipe the output through
[81fd230]170<userinput>grep -A7 Summ</userinput>.</para>
[73aedd1d]171
[e9f146e]172<para>Results can be compared with those located at <ulink
173url="&test-results;"/>.</para>
[81fd230]174
175<para>A few unexpected failures cannot always be avoided. The
176GCC developers are usually aware of these issues, but have not
177resolved them yet. Unless the test results are vastly different from
178those at the above URL, it is safe to continue.</para>
[ede9b9b]179
[81fd230]180<para>Install the package:</para>
[73aedd1d]181
182<screen><userinput>make install</userinput></screen>
183
[81fd230]184<note><para>At this point it is strongly recommended to repeat the
185sanity check we performed earlier in this chapter. Refer back to <xref
186linkend="ch-tools-adjusting" role=","/> and repeat the test compilation. If
187the result is wrong, the most likely reason is that the GCC Specs
188patch was not properly applied.</para></note>
[73aedd1d]189
190</sect2>
[bc82645e]191
[81fd230]192<sect2 role="content"><title/>
193<para>Details on this package are located in <xref
194linkend="contents-gcc" role="."/></para>
195</sect2>
196
[bc82645e]197</sect1>
[81fd230]198
Note: See TracBrowser for help on using the repository browser.