gcc-pass1.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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>&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 a C++ compiler
  13. for the moment.</para>
  14. <para>This package is known to behave badly when you have changed its
  15. default optimization flags (including the -march and -mcpu options).
  16. Therefore, if you have defined any environment variables that override
  17. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  18. or modifying 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 <userinput>gcc</userinput>'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 <userinput>gcc</userinput> binaries will still be linked
  41. statically, as this is controlled by the <userinput>-static</userinput>
  42. value of BOOT_LDFLAGS further on.</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. This is the point where we would normally
  61. run the test suite. But as discussed earlier, we don't recommend running the
  62. test suites for the temporary tools here in this chapter. However, even if we
  63. still wanted to run the GCC test suite, we're unable do so at this early stage
  64. because the test suite framework is not yet in place. Not only that, the
  65. programs from this first pass will soon be overwritten by those installed in
  66. the second pass.</para>
  67. <para>And install the package:</para>
  68. <screen><userinput>make install</userinput></screen>
  69. <para>As a finishing touch we'll create the <filename
  70. class="symlink">/tools/bin/cc</filename> symlink. Many programs and
  71. scripts run <userinput>cc</userinput> instead of <userinput>gcc</userinput>,
  72. a thing meant to keep programs generic and therefore usable on all kinds of
  73. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  74. <userinput>cc</userinput> leaves the system administrator free to decide what
  75. C compiler to install, as long as there's a symlink pointing to it:</para>
  76. <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
  77. </sect2>
  78. <sect2><title>&nbsp;</title><para>&nbsp;</para>
  79. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  80. <para>&nbsp;</para></sect2>
  81. </sect1>