source: chapter05/gcc-pass1.xml@ 673b0d8

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 673b0d8 was 673b0d8, checked in by Matthew Burgess <matthew@…>, 20 years ago
  • Merged newxml into HEAD

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

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