source: chapter05/gcc-pass1-inst.xml@ 0939e573

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 0939e573 was 0939e573, checked in by Gerard Beekmans <gerard@…>, 21 years ago

note not to remove tcl directory

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

  • Property mode set to 100644
File size: 4.9 KB
Line 
1<sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
2
3<sect2>
4<title>Installation of GCC</title>
5
6<para>We won't be needing a C++ compiler until Chapter 6. So, only
7the gcc-core tarball needs to be unpacked at this time.</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>CFLAGS="-O2 -pipe" \
27&nbsp;&nbsp;&nbsp;&nbsp;../gcc-&gcc-version;/configure --prefix=/stage1 \
28&nbsp;&nbsp;&nbsp;&nbsp;--with-local-prefix=/stage1 \
29&nbsp;&nbsp;&nbsp;&nbsp;--disable-nls --enable-shared \
30&nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c</userinput></screen></para>
31
32<para>The meaning of the configure options are:</para>
33
34<itemizedlist>
35<listitem><para><userinput>--prefix=/static</userinput>: This is NOT a
36typo. GCC hard codes some paths while compiling and so we need to pass
37<filename class="directory">/static</filename> as the prefix during the
38configure stage. We will pass the real installation prefix (<filename
39class="directory">$LFS/static</filename>) during the installation
40stage later on.</para></listitem>
41
42<listitem><para><userinput>--disable-shared</userinput>: This prevents the
43build of dynamic libraries. They are useless to us at the moment. We'll
44create them when we reinstall GCC in chapter 6.</para></listitem>
45
46<listitem><para><userinput>--with-as=$LFS/static/bin/as and
47--with-ld=$LFS/static/bin/ld</userinput>: GCC can be miscompiled if your
48host distribution's Binutils package is quite old. We need a good working
49static GCC until we reinstall GCC later in chapter 6. So by using
50<filename>as</filename> and <filename>ld</filename> from the Binutils
51package we compiled earlier in this chapter we ensure that GCC will work
52correctly.</para></listitem>
53</itemizedlist>
54
55<para>Continue with compiling the package:</para>
56
57<para><screen><userinput>make BOOT_LDFLAGS="-static -s" \
58&nbsp;&nbsp;&nbsp;&nbsp;BOOT_CFLAGS="-O2 -pipe" \
59&nbsp;&nbsp;&nbsp;&nbsp;STAGE1_CFLAGS="-pipe" bootstrap</userinput></screen></para>
60
61<para>The meaning of the make options are:</para>
62
63<itemizedlist>
64<listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This is
65GCC's equivalent to make LDFLAGS="-static" as we use with other packages to
66compile them statically.</para></listitem>
67
68<listitem><para><userinput>bootstrap</userinput>: The
69<emphasis>bootstrap</emphasis> target doesn't just compile GCC, but it
70compiles GCC a second time. It uses the first compiled programs to compile
71itself a second and third time to make sure the compiler was compiled properly
72and can compile itself properly.</para></listitem>
73</itemizedlist>
74
75<para>And finish off installing the package:</para>
76
77<para><screen><userinput>make install</userinput></screen></para>
78
79<para>The meaning of the make option is:</para>
80
81<itemizedlist>
82<listitem><para><userinput>install-no-fixedincludes</userinput>: This prevents
83the fixincludes script from running. Preventing this is necessary because
84under normal circumstances the GCC installation will run the fixincludes
85script which scans your system for header files that need to be fixed. It
86might find that the Glibc header files of your host system need to be fixed.
87If so, it will fix them and put them in
88<filename>$LFS/static/lib/gcc-lib/i686-pc-linux-gnu/3.2</filename>. Later on
89in chapter 6 you will install Glibc which will put its header files in
90<filename>/usr/include</filename>. Next you will install other programs that
91use the Glibc headers and GCC will look in
92<filename>/static/lib/gcc-lib</filename> before looking in
93<filename>/usr/include</filename>, with the result of finding and using the
94fixed Glibc header files from your host distribution, which are probably
95incompatible with the Glibc version actually used on the LFS
96system.</para></listitem>
97</itemizedlist>
98
99<para>As the finishing touch we'll create the <filename
100class="symlink">$LFS/static/bin/cc</filename> symlink. A lot of programs
101and scripts try to run <userinput>cc</userinput> instead of
102<userinput>gcc</userinput> This is to keep programs generic and usable on
103all kinds of Unix systems. Not everybody has GNU CC installed. Just running
104<userinput>cc</userinput> (C Compiler) leaves the user free to decide which
105C compiler to install. The symlink will point to the system's default
106compiler.</para>
107
108<para><screen><userinput>ln -sf gcc /stage1/bin/cc</userinput></screen></para>
109
110</sect2>
111
Note: See TracBrowser for help on using the repository browser.