source: chapter05/gcc-pass1.xml@ ede9b9b

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

Minor textual shuffles.

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

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