gcc-pass1.xml 4.5 KB

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