gcc-pass1.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-tools-gcc-pass1" role="wrap">
  7. <title>GCC-&gcc-version; - Pass 1</title>
  8. <?dbhtml filename="gcc-pass1.html"?>
  9. <indexterm zone="ch-tools-gcc-pass1">
  10. <primary sortas="a-GCC">GCC</primary>
  11. <secondary>tools, pass 1</secondary></indexterm>
  12. <sect2 role="package"><title/>
  13. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  14. <segmentedlist>
  15. <segtitle>&buildtime;</segtitle>
  16. <segtitle>&diskspace;</segtitle>
  17. <seglistitem><seg>4.4 SBU</seg><seg>300 MB</seg></seglistitem>
  18. </segmentedlist>
  19. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
  20. </sect2>
  21. <sect2 role="installation">
  22. <title>Installation of GCC</title>
  23. <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
  24. nor the test suite here.</para>
  25. <para>This package is known to behave badly when you change its default
  26. optimization flags (including the <parameter>-march</parameter> and
  27. <parameter>-mcpu</parameter> options). Therefore, if you have defined any
  28. environment variables that override default optimizations, such as CFLAGS and
  29. CXXFLAGS, we recommend un-setting them when building GCC.</para>
  30. <para>The GCC documentation recommends building GCC outside of the source
  31. directory in a dedicated build directory:</para>
  32. <screen><userinput>mkdir ../gcc-build
  33. cd ../gcc-build</userinput></screen>
  34. <para>Prepare GCC for compilation:</para>
  35. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  36. --libexecdir=/tools/lib --with-local-prefix=/tools \
  37. --disable-nls --enable-shared --enable-languages=c</userinput></screen>
  38. <para>The meaning of the configure options:</para>
  39. <variablelist>
  40. <varlistentry>
  41. <term><parameter>--with-local-prefix=/tools</parameter></term>
  42. <listitem><para>The purpose of this switch is to remove <filename class="directory">/usr/local/include</filename>
  43. from <command>gcc</command>'s include search path. This is not absolutely
  44. essential; however, we want to try to minimize the influence of the host
  45. system, so this a sensible thing to do.</para></listitem>
  46. </varlistentry>
  47. <varlistentry>
  48. <term><parameter>--enable-shared</parameter></term>
  49. <listitem><para>This switch may
  50. seem counter-intuitive at first. But using it allows the building of
  51. <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
  52. having <filename>libgcc_eh.a</filename> available ensures that the configure
  53. script for Glibc (the next package we compile) produces the proper results.
  54. Note that the GCC binaries will still be linked
  55. statically, as this is controlled by the <parameter>-static</parameter>
  56. value of BOOT_LDFLAGS in the next step.</para></listitem>
  57. </varlistentry>
  58. <varlistentry>
  59. <term><parameter>--enable-languages=c</parameter></term>
  60. <listitem><para>This option
  61. ensures that only the C compiler is built. The option is only needed when you
  62. have downloaded and unpacked the full GCC tarball.</para></listitem>
  63. </varlistentry>
  64. </variablelist>
  65. <para>Continue with compiling the package:</para>
  66. <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
  67. <para>The meaning of the make parameters:</para>
  68. <variablelist>
  69. <varlistentry>
  70. <term><parameter>BOOT_LDFLAGS="-static"</parameter></term>
  71. <listitem><para>This tells GCC to link its programs statically.</para></listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term><parameter>bootstrap</parameter></term>
  75. <listitem><para>This target doesn't just
  76. compile GCC, but compiles it several times. It uses the programs compiled in
  77. a first round to compile itself a second time, and then again a third time.
  78. It then compares these second and third compiles to make sure it can
  79. reproduce itself flawlessly, which most probably means that it was
  80. compiled correctly.</para></listitem>
  81. </varlistentry>
  82. </variablelist>
  83. <para>Compilation is now complete, and at this point we would normally run the
  84. test suite. But, as mentioned before, the test suite framework is not in place
  85. yet. And there would be little point in running the tests anyhow, since the
  86. programs from this first pass will soon be replaced.</para>
  87. <para>Now install the package:</para>
  88. <screen><userinput>make install</userinput></screen>
  89. <para>As a finishing touch we'll create a symlink. Many programs and scripts
  90. run <command>cc</command> instead of <command>gcc</command>,
  91. a thing meant to keep programs generic and therefore usable on all kinds of
  92. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  93. <command>cc</command> leaves the system administrator free to decide what
  94. C compiler to install, as long as there's a symlink pointing to it:</para>
  95. <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
  96. </sect2>
  97. <sect2 role="content"><title/>
  98. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  99. </sect2>
  100. </sect1>