source: chapter05/gcc-pass1.xml@ f040abe

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 v5_1 v5_1_1 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 f040abe was f040abe, checked in by Alex Gronenwoud <alex@…>, 20 years ago

Making crossreferences from chapter 5 to 6.

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

  • Property mode set to 100644
File size: 4.2 KB
Line 
1<sect1 id="ch05-gcc-pass1">
2<title>Installing GCC-&gcc-version; - Pass 1</title>
3<?dbhtml filename="gcc-pass1.html" dir="chapter05"?>
4
5<screen>Estimated build time: &gcc-time-tools-pass1;
6Estimated required disk space: &gcc-compsize-tools-pass1;</screen>
7
8<para>For the package details see <xref linkend="contents-gcc"/>.</para>
9
10<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
11
12<sect2>
13<title>Installation of GCC</title>
14
15<para>Unpack only the GCC-core tarball, as we won't be needing a C++ compiler
16for the moment.</para>
17
18<note><para>Even though GCC is an important toolchain package, we are not
19going to run the test suite at this early stage. First, the test suite framework
20is not yet in place and second, the programs from this first pass will soon be
21overwritten by those installed in the second pass.</para></note>
22
23<para>This package is known to behave badly when you have changed its
24default optimization flags (including the -march and -mcpu options).
25Therefore, if you have defined any environment variables that override
26default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
27or modifying them when building GCC.</para>
28
29<para>The GCC documentation recommends building GCC outside of the source
30directory in a dedicated build directory:</para>
31
32<screen><userinput>mkdir ../gcc-build
33cd ../gcc-build</userinput></screen>
34
35<para>Prepare GCC for compilation:</para>
36
37<screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
38&nbsp;&nbsp;&nbsp;&nbsp;--with-local-prefix=/tools \
39&nbsp;&nbsp;&nbsp;&nbsp;--disable-nls --enable-shared \
40&nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c</userinput></screen>
41
42<para>The meaning of the configure options:</para>
43
44<itemizedlist>
45<listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
46purpose of this switch is to remove <filename>/usr/local/include</filename>
47from <userinput>gcc</userinput>'s include search path. This is not absolutely
48essential; however, we want to try to minimize the influence of the host
49system, thus making this a sensible thing to do.</para></listitem>
50
51<listitem><para><userinput>--enable-shared</userinput>: This switch may
52seem counter-intuitive at first. But using it allows the building of
53<filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
54having <filename>libgcc_eh.a</filename> available ensures that the configure
55script for Glibc (the next package we compile) produces the proper results.
56Note that the <userinput>gcc</userinput> binaries will still be linked
57statically, as this is controlled by the <userinput>-static</userinput>
58value of BOOT_LDFLAGS further on.</para></listitem>
59
60<listitem><para><userinput>--enable-languages=c</userinput>: This option
61ensures that only the C compiler is built. The option is only needed when you
62have downloaded and unpacked the full GCC tarball.</para></listitem>
63</itemizedlist>
64
65<para>Continue with compiling the package:</para>
66
67<screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
68
69<para>The meaning of the make parameters:</para>
70
71<itemizedlist>
72<listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
73GCC to link its programs statically.</para></listitem>
74
75<listitem><para><userinput>bootstrap</userinput>: This target doesn't just
76compile GCC, but compiles it several times. It uses the programs compiled in
77a first round to compile itself a second time, and then again a third time.
78It then compares these second and third compiles to make sure it can
79reproduce itself flawlessly, which most probably means that it was
80compiled correctly.</para></listitem>
81</itemizedlist>
82
83<para>And install the package:</para>
84
85<screen><userinput>make install</userinput></screen>
86
87<para>As a finishing touch we'll create the <filename
88class="symlink">/tools/bin/cc</filename> symlink. Many programs and
89scripts run <userinput>cc</userinput> instead of <userinput>gcc</userinput>,
90a thing meant to keep programs generic and therefore usable on all kinds of
91Unix systems. Not everybody has the GNU C compiler installed. Simply running
92<userinput>cc</userinput> leaves the system administrator free to decide what
93C compiler to install, as long as there's a symlink pointing to it:</para>
94
95<screen><userinput>ln -sf gcc /tools/bin/cc</userinput></screen>
96
97</sect2>
98
99</sect1>
100
Note: See TracBrowser for help on using the repository browser.