gcc-pass1.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-tools-gcc-pass1" role="wrap">
  8. <?dbhtml filename="gcc-pass1.html"?>
  9. <sect1info condition="script">
  10. <productname>gcc</productname>
  11. <productnumber>&gcc-version;</productnumber>
  12. <address>&gcc-url;</address>
  13. </sect1info>
  14. <title>GCC-&gcc-version; - Pass 1</title>
  15. <indexterm zone="ch-tools-gcc-pass1">
  16. <primary sortas="a-GCC">GCC</primary>
  17. <secondary>tools, pass 1</secondary>
  18. </indexterm>
  19. <sect2 role="package">
  20. <title/>
  21. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  22. href="../chapter06/gcc.xml"
  23. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  24. <segmentedlist>
  25. <segtitle>&buildtime;</segtitle>
  26. <segtitle>&diskspace;</segtitle>
  27. <seglistitem>
  28. <seg>&gcc-ch5p1-sbu;</seg>
  29. <seg>&gcc-ch5p1-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>Installation of GCC</title>
  35. <para>GCC now requires the GMP and MPFR packages. As these packages may
  36. not be included in your host distribution, they will be built with
  37. GCC.</para>
  38. <screen><userinput remap="pre">tar -jxf ../mpfr-&mpfr-version;.tar.bz2
  39. mv mpfr-&mpfr-version; mpfr
  40. tar -jxf ../gmp-&gmp-version;.tar.bz2
  41. mv gmp-&gmp-version; gmp</userinput></screen>
  42. <para>The GCC documentation recommends building GCC outside of the
  43. source directory in a dedicated build directory:</para>
  44. <screen><userinput remap="pre">mkdir -v ../gcc-build
  45. cd ../gcc-build</userinput></screen>
  46. <para>Prepare GCC for compilation:</para>
  47. <screen><userinput remap="configure">CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
  48. --with-local-prefix=/tools --disable-nls --disable-shared --disable-libssp \
  49. --enable-languages=c</userinput></screen>
  50. <variablelist>
  51. <title>The meaning of the configure options:</title>
  52. <varlistentry>
  53. <term><envar>CC="gcc -B/usr/bin/"</envar></term>
  54. <listitem>
  55. <para>This forces <command>gcc</command> to prefer the linker from
  56. the host in <filename class="directory">/usr/bin</filename>. This
  57. is necessary on some hosts where the new <command>ld</command>
  58. built in the previous section is not compatible with the host's
  59. <command>gcc</command>.</para>
  60. </listitem>
  61. </varlistentry>
  62. <varlistentry>
  63. <term><parameter>--with-local-prefix=/tools</parameter></term>
  64. <listitem>
  65. <para>The purpose of this switch is to remove <filename
  66. class="directory">/usr/local/include</filename> from
  67. <command>gcc</command>'s include search path. This is not
  68. absolutely essential, however, it helps to minimize the
  69. influence of the host system.</para>
  70. </listitem>
  71. </varlistentry>
  72. <varlistentry>
  73. <term><parameter>--disable-shared</parameter></term>
  74. <listitem>
  75. <para>This switch forces GCC to link its internal libraries
  76. statically. We do this to avoid possible issues with the host
  77. system.</para>
  78. </listitem>
  79. </varlistentry>
  80. <varlistentry>
  81. <term><parameter>--disable-libssp</parameter></term>
  82. <listitem>
  83. <para>This switch prevents a conflict with older versions of
  84. glibc which can cause the build to fail.</para>
  85. </listitem>
  86. </varlistentry>
  87. <varlistentry>
  88. <term><parameter>--enable-languages=c</parameter></term>
  89. <listitem>
  90. <para>This option ensures that only the C compiler is built.
  91. This is the only language needed now.</para>
  92. </listitem>
  93. </varlistentry>
  94. <varlistentry>
  95. <term><parameter>--disable-multilib</parameter></term>
  96. <listitem>
  97. <para>We currently only want to build support for 64-bit libraries.</para>
  98. </listitem>
  99. </varlistentry>
  100. </variablelist>
  101. <para>The following command will compile GCC not once, but several times. It
  102. uses the programs compiled in a first round to compile itself a second time,
  103. and then again a third time. It then compares these second and third compiles
  104. to make sure it can reproduce itself flawlessly. This is called
  105. <quote>bootstrapping</quote>. Building GCC in this way ensures that it was
  106. compiled correctly and is now the default configuration for the released
  107. package. Continue with compiling by running:</para>
  108. <screen><userinput remap="make">make</userinput></screen>
  109. <para>Compilation is now complete. At this point, the test suite would
  110. normally be run, but, as mentioned before, the test suite framework is
  111. not in place yet. The benefits of running the tests at this point
  112. are minimal since the programs from this first pass will soon be
  113. replaced.</para>
  114. <para>Install the package:</para>
  115. <screen><userinput remap="install">make install</userinput></screen>
  116. <para>Using <parameter>--disable-shared</parameter> means that the
  117. <filename>libgcc_eh.a</filename> file isn't created and installed. The
  118. Glibc package depends on this library as it uses
  119. <parameter>-lgcc_eh</parameter> within its build system. We can satisfy
  120. that dependency by creating a symlink to <filename>libgcc.a</filename>,
  121. since that file will end up containing the objects normally contained in
  122. <filename>libgcc_eh.a</filename>.</para>
  123. <screen><userinput remap="install">ln -vs libgcc.a `gcc -print-libgcc-file-name | \
  124. sed 's/libgcc/&amp;_eh/'`</userinput></screen>
  125. <para>As a finishing touch, create a symlink. Many programs and scripts
  126. run <command>cc</command> instead of <command>gcc</command>, which is
  127. used to keep programs generic and therefore usable on all kinds of UNIX
  128. systems where the GNU C compiler is not always installed. Running
  129. <command>cc</command> leaves the system administrator free to decide
  130. which C compiler to install:</para>
  131. <screen><userinput remap="install">ln -vs gcc /tools/bin/cc</userinput></screen>
  132. </sect2>
  133. <sect2 role="content">
  134. <title/>
  135. <para>Details on this package are located in
  136. <xref linkend="contents-gcc" role="."/></para>
  137. </sect2>
  138. </sect1>