gcc-pass1.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. <title>GCC-&gcc-version; - Pass 1</title>
  10. <indexterm zone="ch-tools-gcc-pass1">
  11. <primary sortas="a-GCC">GCC</primary>
  12. <secondary>tools, pass 1</secondary>
  13. </indexterm>
  14. <sect2 role="package">
  15. <title/>
  16. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  17. href="../chapter06/gcc.xml"
  18. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  19. <segmentedlist>
  20. <segtitle>&buildtime;</segtitle>
  21. <segtitle>&diskspace;</segtitle>
  22. <seglistitem>
  23. <seg>&gcc-ch5p1-sbu;</seg>
  24. <seg>&gcc-ch5p1-du;</seg>
  25. </seglistitem>
  26. </segmentedlist>
  27. </sect2>
  28. <sect2 role="installation">
  29. <title>Installation of GCC</title>
  30. <para>The GCC documentation recommends building GCC outside of the
  31. source directory in a dedicated build directory:</para>
  32. <screen><userinput>mkdir -v ../gcc-build
  33. cd ../gcc-build</userinput></screen>
  34. <para>Prepare GCC for compilation:</para>
  35. <screen><userinput>CC="gcc -B/usr/bin/" ../gcc-&gcc-version;/configure --prefix=/tools \
  36. --with-local-prefix=/tools --disable-nls --disable-shared \
  37. --enable-languages=c --disable-multilib --with-arch=i486</userinput></screen>
  38. <variablelist>
  39. <title>The meaning of the configure options:</title>
  40. <varlistentry>
  41. <term><envar>CC="gcc -B/usr/bin/"</envar></term>
  42. <listitem>
  43. <para>This forces <command>gcc</command> to prefer the linker from
  44. the host in <filename class="directory">/usr/bin</filename>. This
  45. is necessary on some hosts where the new <command>ld</command>
  46. built in the previous section is not compatible with the host's
  47. <command>gcc</command>.</para>
  48. </listitem>
  49. </varlistentry>
  50. <varlistentry>
  51. <term><parameter>--with-local-prefix=/tools</parameter></term>
  52. <listitem>
  53. <para>The purpose of this switch is to remove <filename
  54. class="directory">/usr/local/include</filename> from
  55. <command>gcc</command>'s include search path. This is not
  56. absolutely essential, however, it helps to minimize the
  57. influence of the host system.</para>
  58. </listitem>
  59. </varlistentry>
  60. <varlistentry>
  61. <term><parameter>--disable-shared</parameter></term>
  62. <listitem>
  63. <para>This forces gcc to link its internal libraries statically. We do this
  64. to avoid possible issues with the host system.</para>
  65. </listitem>
  66. </varlistentry>
  67. <varlistentry>
  68. <term><parameter>--enable-languages=c</parameter></term>
  69. <listitem>
  70. <para>This option ensures that only the C compiler is built.</para>
  71. </listitem>
  72. </varlistentry>
  73. <varlistentry>
  74. <term><parameter>--disable-multilib</parameter></term>
  75. <listitem>
  76. <para>We currently only want to build support for 64-bit libraries.</para>
  77. </listitem>
  78. </varlistentry>
  79. <varlistentry>
  80. <term><parameter>--with-arch=i486</parameter></term>
  81. <listitem>
  82. <para>On x86 machines Glibc needs to be built for a minimum architecture
  83. of <quote>i486</quote>. Setting this for the GCC build ensures that the
  84. entire system is built consistently.</para>
  85. </listitem>
  86. </varlistentry>
  87. </variablelist>
  88. <para>Continue with compiling the package:</para>
  89. <screen><userinput>make bootstrap</userinput></screen>
  90. <variablelist>
  91. <title>The meaning of the make parameter:</title>
  92. <varlistentry>
  93. <term><parameter>bootstrap</parameter></term>
  94. <listitem>
  95. <para>This target does not just compile GCC, but compiles it
  96. several times. It uses the programs compiled in a first round
  97. to compile itself a second time, and then again a third time.
  98. It then compares these second and third compiles to make sure
  99. it can reproduce itself flawlessly. This also implies that it
  100. was compiled correctly.</para>
  101. </listitem>
  102. </varlistentry>
  103. </variablelist>
  104. <para>Compilation is now complete. At this point, the test suite would
  105. normally be run, but, as mentioned before, the test suite framework is
  106. not in place yet. The benefits of running the tests at this point
  107. are minimal since the programs from this first pass will soon be
  108. replaced.</para>
  109. <para>Install the package:</para>
  110. <screen><userinput>make install</userinput></screen>
  111. <para>Using <command>--disable-shared</command> means that the file
  112. <filename class="libraryfile">libgcc_eh.a</filename>
  113. isn't created and installed. The next package, Glibc, depends on this
  114. library as it uses <command>-lgcc_eh</command> within its build system.
  115. We can satisfy that dependency by creating a symlink to
  116. <filename class="libraryfile">libgcc.a</filename>, since that file will
  117. end up containing the objects normally contained in
  118. <filename class="libraryfile">libgcc_eh.a</filename>.</para>
  119. <screen><userinput>ln -vs libgcc.a `gcc -print-libgcc-file-name | \
  120. sed 's/libgcc/&amp;_eh/'`</userinput></screen>
  121. <para>As a finishing touch, create a symlink. Many programs and scripts
  122. run <command>cc</command> instead of <command>gcc</command>, which is
  123. used to keep programs generic and therefore usable on all kinds of UNIX
  124. systems where the GNU C compiler is not always installed. Running
  125. <command>cc</command> leaves the system administrator free to decide
  126. which C compiler to install:</para>
  127. <screen><userinput>ln -vs gcc /tools/bin/cc</userinput></screen>
  128. </sect2>
  129. <sect2 role="content">
  130. <title/>
  131. <para>Details on this package are located in
  132. <xref linkend="contents-gcc" role="."/></para>
  133. </sect2>
  134. </sect1>