source: chapter05/gcc-pass1.xml@ 9652249

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 9652249 was 9652249, checked in by Manuel Canales Esparcia <manuel@…>, 20 years ago

HEAD: Retaged the SBUs/disk-usage sections, the lists of options and the contents sections in chapter05.

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

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