[7681a57] | 1 | <sect2><title> </title><para> </para></sect2>
|
---|
| 2 |
|
---|
[6370fa6] | 3 | <sect2>
|
---|
[a36091d] | 4 | <title>Installation of GCC</title>
|
---|
[6370fa6] | 5 |
|
---|
[4e010de] | 6 | <para>We won't be needing a C++ compiler until Chapter 6. So, only
|
---|
| 7 | the gcc-core tarball needs to be unpacked at this time.</para>
|
---|
| 8 |
|
---|
[e69a59f] | 9 | <para>This package is known to behave badly when you have changed its
|
---|
[2b114b25] | 10 | default optimization flags (including the -march and -mcpu options).
|
---|
| 11 | Therefore, if you have defined any environment variables that override
|
---|
| 12 | default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
|
---|
| 13 | or modifying them when building GCC.</para>
|
---|
[b43aab1] | 14 |
|
---|
[bc82645e] | 15 | <para><screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-mmap_test.patch
|
---|
[0939e573] | 16 | patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes.patch</userinput></screen></para>
|
---|
[bc82645e] | 17 |
|
---|
[7681a57] | 18 | <para>It is recommended by the GCC installation documentation to build
|
---|
| 19 | GCC outside of the source directory in a dedicated directory:</para>
|
---|
| 20 |
|
---|
| 21 | <para><screen><userinput>mkdir ../gcc-build
|
---|
| 22 | cd ../gcc-build</userinput></screen></para>
|
---|
| 23 |
|
---|
| 24 | <para>Prepare GCC to be compiled:</para>
|
---|
[6370fa6] | 25 |
|
---|
[84a7dc2] | 26 | <para><screen><userinput>../gcc-&gcc-version;/configure --prefix=/stage1 \
|
---|
[bc82645e] | 27 | --with-local-prefix=/stage1 \
|
---|
[0939e573] | 28 | --disable-nls --enable-shared \
|
---|
| 29 | --enable-languages=c</userinput></screen></para>
|
---|
[7681a57] | 30 |
|
---|
| 31 | <para>The meaning of the configure options are:</para>
|
---|
| 32 |
|
---|
| 33 | <itemizedlist>
|
---|
[e4b9338] | 34 | <listitem><para><userinput>--prefix=/static</userinput>: This is NOT a
|
---|
[7681a57] | 35 | typo. GCC hard codes some paths while compiling and so we need to pass
|
---|
| 36 | <filename class="directory">/static</filename> as the prefix during the
|
---|
[558cb8a] | 37 | configure stage. We will pass the real installation prefix (<filename
|
---|
[e4b9338] | 38 | class="directory">$LFS/static</filename>) during the installation
|
---|
[7681a57] | 39 | stage later on.</para></listitem>
|
---|
| 40 |
|
---|
[e4b9338] | 41 | <listitem><para><userinput>--disable-shared</userinput>: This prevents the
|
---|
[7681a57] | 42 | build of dynamic libraries. They are useless to us at the moment. We'll
|
---|
| 43 | create them when we reinstall GCC in chapter 6.</para></listitem>
|
---|
| 44 |
|
---|
| 45 | <listitem><para><userinput>--with-as=$LFS/static/bin/as and
|
---|
[e4b9338] | 46 | --with-ld=$LFS/static/bin/ld</userinput>: GCC can be miscompiled if your
|
---|
[7681a57] | 47 | host distribution's Binutils package is quite old. We need a good working
|
---|
| 48 | static GCC until we reinstall GCC later in chapter 6. So by using
|
---|
| 49 | <filename>as</filename> and <filename>ld</filename> from the Binutils
|
---|
| 50 | package we compiled earlier in this chapter we ensure that GCC will work
|
---|
| 51 | correctly.</para></listitem>
|
---|
| 52 | </itemizedlist>
|
---|
| 53 |
|
---|
| 54 | <para>Continue with compiling the package:</para>
|
---|
| 55 |
|
---|
[84a7dc2] | 56 | <para><screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen></para>
|
---|
[7681a57] | 57 |
|
---|
| 58 | <para>The meaning of the make options are:</para>
|
---|
| 59 |
|
---|
| 60 | <itemizedlist>
|
---|
[e4b9338] | 61 | <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This is
|
---|
[7681a57] | 62 | GCC's equivalent to make LDFLAGS="-static" as we use with other packages to
|
---|
| 63 | compile them statically.</para></listitem>
|
---|
| 64 |
|
---|
[e4b9338] | 65 | <listitem><para><userinput>bootstrap</userinput>: The
|
---|
[7681a57] | 66 | <emphasis>bootstrap</emphasis> target doesn't just compile GCC, but it
|
---|
| 67 | compiles GCC a second time. It uses the first compiled programs to compile
|
---|
[e4b9338] | 68 | itself a second and third time to make sure the compiler was compiled properly
|
---|
[7681a57] | 69 | and can compile itself properly.</para></listitem>
|
---|
| 70 | </itemizedlist>
|
---|
| 71 |
|
---|
| 72 | <para>And finish off installing the package:</para>
|
---|
| 73 |
|
---|
[bc82645e] | 74 | <para><screen><userinput>make install</userinput></screen></para>
|
---|
[7681a57] | 75 |
|
---|
| 76 | <para>The meaning of the make option is:</para>
|
---|
| 77 |
|
---|
| 78 | <itemizedlist>
|
---|
[e4b9338] | 79 | <listitem><para><userinput>install-no-fixedincludes</userinput>: This prevents
|
---|
[7681a57] | 80 | the fixincludes script from running. Preventing this is necessary because
|
---|
| 81 | under normal circumstances the GCC installation will run the fixincludes
|
---|
| 82 | script which scans your system for header files that need to be fixed. It
|
---|
| 83 | might find that the Glibc header files of your host system need to be fixed.
|
---|
| 84 | If so, it will fix them and put them in
|
---|
| 85 | <filename>$LFS/static/lib/gcc-lib/i686-pc-linux-gnu/3.2</filename>. Later on
|
---|
| 86 | in chapter 6 you will install Glibc which will put its header files in
|
---|
| 87 | <filename>/usr/include</filename>. Next you will install other programs that
|
---|
[558cb8a] | 88 | use the Glibc headers and GCC will look in
|
---|
[7681a57] | 89 | <filename>/static/lib/gcc-lib</filename> before looking in
|
---|
| 90 | <filename>/usr/include</filename>, with the result of finding and using the
|
---|
| 91 | fixed Glibc header files from your host distribution, which are probably
|
---|
| 92 | incompatible with the Glibc version actually used on the LFS
|
---|
| 93 | system.</para></listitem>
|
---|
| 94 | </itemizedlist>
|
---|
| 95 |
|
---|
| 96 | <para>As the finishing touch we'll create the <filename
|
---|
| 97 | class="symlink">$LFS/static/bin/cc</filename> symlink. A lot of programs
|
---|
| 98 | and scripts try to run <userinput>cc</userinput> instead of
|
---|
| 99 | <userinput>gcc</userinput> This is to keep programs generic and usable on
|
---|
| 100 | all kinds of Unix systems. Not everybody has GNU CC installed. Just running
|
---|
[e4b9338] | 101 | <userinput>cc</userinput> (C Compiler) leaves the user free to decide which
|
---|
| 102 | C compiler to install. The symlink will point to the system's default
|
---|
| 103 | compiler.</para>
|
---|
[7681a57] | 104 |
|
---|
[bc82645e] | 105 | <para><screen><userinput>ln -sf gcc /stage1/bin/cc</userinput></screen></para>
|
---|
[6370fa6] | 106 |
|
---|
| 107 | </sect2>
|
---|
| 108 |
|
---|