gcc-pass1.xml 4.2 KB

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