gcc-pass1.xml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <sect1 id="ch-tools-gcc-pass1">
  2. <title>Installing GCC-&gcc-version; - Pass 1</title>
  3. <?dbhtml filename="gcc-pass1.html" dir="chapter05"?>
  4. <screen>&buildtime; &gcc-time-tools-pass1;
  5. &diskspace; &gcc-compsize-tools-pass1;</screen>
  6. <literallayout>Official download location for GCC (&gcc-version;):
  7. <ulink url="ftp://ftp.gnu.org/pub/gnu/gcc/"/></literallayout>
  8. &aa-gcc-dep;
  9. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  10. <sect2>
  11. <title>Installation of GCC</title>
  12. <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
  13. nor the test suite at the moment.</para>
  14. <para>This package is known to behave badly when you change its default
  15. optimization flags (including the <emphasis>-march</emphasis> and
  16. <emphasis>-mcpu</emphasis> options). Therefore, if you have defined any
  17. environment variables that override default optimizations, such as CFLAGS and
  18. CXXFLAGS, we recommend unsetting them when building GCC.</para>
  19. <para>The GCC documentation recommends building GCC outside of the source
  20. directory in a dedicated build directory:</para>
  21. <screen><userinput>mkdir ../gcc-build
  22. cd ../gcc-build</userinput></screen>
  23. <para>Prepare GCC for compilation:</para>
  24. <screen><userinput>../&gcc-dir;/configure --prefix=/tools \
  25. &nbsp;&nbsp;&nbsp;&nbsp;--with-local-prefix=/tools \
  26. &nbsp;&nbsp;&nbsp;&nbsp;--disable-nls --enable-shared \
  27. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c</userinput></screen>
  28. <para>The meaning of the configure options:</para>
  29. <itemizedlist>
  30. <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
  31. purpose of this switch is to remove <filename>/usr/local/include</filename>
  32. from <command>gcc</command>'s include search path. This is not absolutely
  33. essential; however, we want to try to minimize the influence of the host
  34. system, thus making this a sensible thing to do.</para></listitem>
  35. <listitem><para><userinput>--enable-shared</userinput>: This switch may
  36. seem counter-intuitive at first. But using it allows the building of
  37. <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
  38. having <filename>libgcc_eh.a</filename> available ensures that the configure
  39. script for Glibc (the next package we compile) produces the proper results.
  40. Note that the <command>gcc</command> binaries will still be linked
  41. statically, as this is controlled by the <emphasis>-static</emphasis>
  42. value of BOOT_LDFLAGS in the next step.</para></listitem>
  43. <listitem><para><userinput>--enable-languages=c</userinput>: This option
  44. ensures that only the C compiler is built. The option is only needed when you
  45. have downloaded and unpacked the full GCC tarball.</para></listitem>
  46. </itemizedlist>
  47. <para>Continue with compiling the package:</para>
  48. <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
  49. <para>The meaning of the make parameters:</para>
  50. <itemizedlist>
  51. <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
  52. GCC to link its programs statically.</para></listitem>
  53. <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
  54. compile GCC, but compiles it several times. It uses the programs compiled in
  55. a first round to compile itself a second time, and then again a third time.
  56. It then compares these second and third compiles to make sure it can
  57. reproduce itself flawlessly, which most probably means that it was
  58. compiled correctly.</para></listitem>
  59. </itemizedlist>
  60. <para>Compilation is now complete, and at this point we would normally run the
  61. test suite. But, as mentioned before, the test suite framework is not in place
  62. yet. And there would be little point in running the tests anyhow, since the
  63. programs from this first pass will soon be replaced.</para>
  64. <para>And install the package:</para>
  65. <screen><userinput>make install</userinput></screen>
  66. <para>As a finishing touch we'll create a symlink. Many programs and scripts
  67. run <command>cc</command> instead of <command>gcc</command>,
  68. a thing meant to keep programs generic and therefore usable on all kinds of
  69. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  70. <command>cc</command> leaves the system administrator free to decide what
  71. C compiler to install, as long as there's a symlink pointing to it:</para>
  72. <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
  73. </sect2>
  74. <sect2><title>&nbsp;</title><para>&nbsp;</para>
  75. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  76. <para>&nbsp;</para></sect2>
  77. </sect1>