source: chapter05/gcc-pass2.xml@ c8ba565

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 6.0 6.1 6.1.1 6.3 6.4 6.5 6.6 6.7 6.8 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since c8ba565 was c8ba565, checked in by Zack Winkles <winkie@…>, 20 years ago

Committing current BE-LFS to head.

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

  • Property mode set to 100644
File size: 7.7 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
3 <!ENTITY % general-entities SYSTEM "../general.ent">
4 %general-entities;
5]>
6<sect1 id="ch-tools-gcc-pass2">
7<title>GCC-&gcc-version; - Pass 2</title>
8<?dbhtml filename="gcc-pass2.html"?>
9
10<indexterm zone="ch-tools-gcc-pass2">
11<primary sortas="a-GCC">GCC</primary>
12<secondary>tools, pass 2</secondary></indexterm>
13
14<screen>&buildtime; 11.0 SBU
15&diskspace; 274 MB</screen>
16
17
18<sect2>
19<title>Re-installation of GCC</title>
20
21<para>The tools required to test GCC and Binutils are installed now: Tcl,
22Expect and DejaGnu. Therefore we can now rebuild GCC and Binutils, linking
23them against the new Glibc, and test them properly (if running the test suites
24in this chapter). One thing to note, however, is that these test suites are
25highly dependent on properly functioning pseudo terminals (PTYs) which are
26provided by your host. These days, PTYs are most commonly implemented via the
27<emphasis>devpts</emphasis> file system. You can quickly check if your host
28system is set up correctly in this regard by performing a simple test:</para>
29
30<screen><userinput>expect -c "spawn ls"</userinput></screen>
31
32<para>The response might be:</para>
33
34<blockquote><screen>The system has no more ptys. Ask your system administrator to create more.</screen></blockquote>
35
36<para>If you receive the above message, your host doesn't have its PTYs set up
37properly. In this case there is no point in running the test suites for GCC
38and Binutils until you are able to resolve the issue. You can consult the LFS
39Wiki at <ulink url="&wiki-root;"/> for more information on how to get PTYs
40working.</para>
41
42<para>This time we will build both the C and the C++ compilers, so you'll have
43to unpack both the core and the g++ tarballs (and testsuite too, if you want to
44run the tests). Unpacking them in your working directory, they will all unfold
45into a single <filename>gcc-&gcc-version;/</filename> subdirectory.</para>
46
47<para>First correct a problem and make an essential adjustment:</para>
48
49<screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no-fixincludes-1.patch
50patch -Np1 -i ../gcc-&gcc-version;-specs-1.patch</userinput></screen>
51
52<para>The first patch disables the GCC <quote>fixincludes</quote> script. We
53mentioned this briefly earlier, but a slightly more in-depth explanation of
54the fixincludes process is warranted here. Under normal circumstances, the GCC
55fixincludes script scans your system for header files that need to be fixed. It
56might find that some Glibc header files on your host system need to be fixed,
57fix them and put them in the GCC private include directory. Then, later on in
58<xref linkend="chapter-building-system"/>, after we've installed the newer
59Glibc, this private include directory would be searched before the system
60include directory, resulting in GCC finding the fixed headers from the host
61system, which would most likely not match the Glibc version actually used for
62the LFS system.</para>
63
64<para>The second patch changes GCC's default location of the dynamic linker
65(typically <filename>ld-linux.so.2</filename>). It also removes
66<filename class="directory">/usr/include</filename> from GCC's include search
67path. Patching now rather than adjusting the specs file after installation
68ensures that our new dynamic linker gets used during the actual build of GCC.
69That is, all the final (and temporary) binaries created during the build will
70link against the new Glibc.</para>
71
72<important><para>The above patches are <emphasis>critical</emphasis> in ensuring
73a successful overall build. Do not forget to apply them.</para></important>
74
75<para>Create a separate build directory again:</para>
76
77<screen><userinput>mkdir ../gcc-build
78cd ../gcc-build</userinput></screen>
79
80<para>Before starting to build GCC, remember to unset any environment
81variables that override the default optimization flags.</para>
82
83<para>Now prepare GCC for compilation:</para>
84
85<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
86 --libexecdir=/tools/lib --with-local-prefix=/tools \
87 --enable-clocale=gnu --enable-shared --enable-threads=posix \
88 --enable-__cxa_atexit --enable-languages=c,c++</userinput></screen>
89
90<para>The meaning of the new configure options:</para>
91
92<itemizedlist>
93<listitem><para><userinput>--enable-clocale=gnu</userinput>: This option
94ensures the correct locale model is selected for the C++ libraries under all
95circumstances. If the configure script finds the <emphasis>de_DE</emphasis>
96locale installed, it will select the correct <emphasis>gnu</emphasis> locale
97model. However, people who don't install the <emphasis>de_DE</emphasis> locale
98would run the risk of building ABI incompatible C++ libraries due to the wrong
99<emphasis>generic</emphasis> locale model being selected.</para></listitem>
100
101<listitem><para><userinput>--enable-threads=posix</userinput>: This enables
102C++ exception handling for multi-threaded code.</para></listitem>
103
104<listitem><para><userinput>--enable-__cxa_atexit</userinput>: This option
105allows use of __cxa_atexit, rather than atexit, to register C++ destructors for
106local statics and global objects and is essential for fully standards-compliant
107handling of destructors. It also affects the C++ ABI and therefore results in
108C++ shared libraries and C++ programs that are interoperable with other Linux
109distributions.</para></listitem>
110
111<listitem><para><userinput>--enable-languages=c,c++</userinput>: This option
112ensures that both the C and C++ compilers are built.</para></listitem>
113</itemizedlist>
114
115<para>Compile the package:</para>
116
117<screen><userinput>make</userinput></screen>
118
119<para>There is no need to use the <emphasis>bootstrap</emphasis> target now,
120as the compiler we're using to compile this GCC was built from the exact same
121version of the GCC sources we used earlier.</para>
122
123<para>Compilation is now complete. As mentioned earlier, we don't recommend
124running the test suites for the temporary tools here in this chapter. If you
125still want to run the GCC test suite anyway, the following command will do
126so:</para>
127
128<screen><userinput>make -k check</userinput></screen>
129
130<para>The <emphasis>-k</emphasis> flag is used to make the test suite run
131through to completion and not stop at the first failure. The GCC test suite is
132very comprehensive and is almost guaranteed to generate a few failures. To get
133a summary of the test suite results, run this:</para>
134
135<screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
136
137<para>(For just the summaries, pipe the output through
138<userinput>grep -A7 Summ</userinput>.)</para>
139
140<para>You can compare your results to those posted to the gcc-testresults
141mailing list for similar configurations to your own. For an example of how
142current GCC-&gcc-version; should look on i686-pc-linux-gnu, see
143<ulink url="http://gcc.gnu.org/ml/gcc-testresults/2004-04/msg00414.html"/>.</para>
144
145<para>Having a few unexpected failures often cannot be avoided. The GCC
146developers are usually aware of these, but haven't yet gotten around to fixing
147them. In short, unless your results are vastly different from those at the above
148URL, it is safe to continue.</para>
149
150<para>And finally install the package:</para>
151
152<screen><userinput>make install</userinput></screen>
153
154<note><para>At this point it is strongly recommended to repeat the sanity check
155we performed earlier in this chapter. Refer back to
156<xref linkend="ch-tools-adjusting"/> and repeat the little test compilation. If
157the result is wrong, then most likely you forgot to apply the above mentioned
158GCC Specs patch.</para></note>
159
160</sect2>
161
162<sect2><title> </title><para> </para>
163<para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
164<para> </para></sect2>
165
166</sect1>
Note: See TracBrowser for help on using the repository browser.