source: chapter05/gcc-pass1-inst.xml@ 503e1a6

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 503e1a6 was ab6f1859, checked in by Alex Gronenwoud <alex@…>, 21 years ago

small things around coreutils and bugs #518 and #520

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

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