source: chapter05/gcc-pass1-inst.xml@ b4f6bac

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_0 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 b4f6bac was 21ba4e3, checked in by Greg Schafer <greg@…>, 21 years ago

Internal markup reworking to fix the extraneous whitespace problem in the "tidy generated" web site pages. Essentially replace all ocurrences of <para><screen> with <screen> (and of course the matching closing tags).

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

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