gcc-pass1.xml 4.2 KB

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