gcc-pass1.xml 6.2 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>Test to see if the host is a multilib capable machine and set a variable
  35. if it is. This ensures that only 64-bit binaries are built if using such a host.
  36. Also, the --with-arch flag is only necessary for x86 machines.</para>
  37. <screen><userinput>case $(uname -m) in
  38. x86) WITHARCH="--with-arch=i486" ;;
  39. x86_64) M64="-m64" ;;
  40. esac</userinput></screen>
  41. <para>Prepare GCC for compilation:</para>
  42. <screen><userinput>CC="gcc -B/usr/bin/ $M64" ../gcc-&gcc-version;/configure --prefix=/tools \
  43. --with-local-prefix=/tools --disable-nls --disable-shared \
  44. --enable-languages=c --disable-multilib \
  45. $WITHARCH
  46. unset M64 WITHARCH</userinput></screen>
  47. <variablelist>
  48. <title>The meaning of the configure options:</title>
  49. <varlistentry>
  50. <term><envar>CC="gcc -B/usr/bin/"</envar></term>
  51. <listitem>
  52. <para>This forces <command>gcc</command> to prefer the linker from
  53. the host in <filename class="directory">/usr/bin</filename>. This
  54. is necessary on some hosts where the new <command>ld</command>
  55. built in the previous section is not compatible with the host's
  56. <command>gcc</command>.</para>
  57. </listitem>
  58. </varlistentry>
  59. <varlistentry>
  60. <term><parameter>--with-local-prefix=/tools</parameter></term>
  61. <listitem>
  62. <para>The purpose of this switch is to remove <filename
  63. class="directory">/usr/local/include</filename> from
  64. <command>gcc</command>'s include search path. This is not
  65. absolutely essential, however, it helps to minimize the
  66. influence of the host system.</para>
  67. </listitem>
  68. </varlistentry>
  69. <varlistentry>
  70. <term><parameter>--disable-shared</parameter></term>
  71. <listitem>
  72. <para>This forces gcc to link its internal libraries statically. We do this
  73. to avoid possible issues with the host system.</para>
  74. </listitem>
  75. </varlistentry>
  76. <varlistentry>
  77. <term><parameter>--enable-languages=c</parameter></term>
  78. <listitem>
  79. <para>This option ensures that only the C compiler is built.</para>
  80. </listitem>
  81. </varlistentry>
  82. <varlistentry>
  83. <term><parameter>--disable-multilib</parameter></term>
  84. <listitem>
  85. <para>We currently only want to build support for 64-bit libraries.</para>
  86. </listitem>
  87. </varlistentry>
  88. <varlistentry>
  89. <term><parameter>--with-arch=i486</parameter></term>
  90. <listitem>
  91. <para>On x86 machines Glibc needs to be built for a minimum architecture
  92. of <quote>i486</quote>. Setting this for the GCC build ensures that the
  93. entire system is built consistently.</para>
  94. </listitem>
  95. </varlistentry>
  96. </variablelist>
  97. <para>The following command will compile GCC not once, but several times. It
  98. uses the programs compiled in a first round to compile itself a second time,
  99. and then again a third time. It then compares these second and third compiles
  100. to make sure it can reproduce itself flawlessly. This is called
  101. <quote>bootstrapping</quote>. Building GCC in this way ensures that it was
  102. compiled correctly and is now the default configuration for the released
  103. package. Continue with compiling by running:</para>
  104. <screen><userinput>make</userinput></screen>
  105. <para>Compilation is now complete. At this point, the test suite would
  106. normally be run, but, as mentioned before, the test suite framework is
  107. not in place yet. The benefits of running the tests at this point
  108. are minimal since the programs from this first pass will soon be
  109. replaced.</para>
  110. <para>Install the package:</para>
  111. <screen><userinput>make install</userinput></screen>
  112. <para>Using <command>--disable-shared</command> means that the file
  113. <filename class="libraryfile">libgcc_eh.a</filename>
  114. isn't created and installed. The next package, Glibc, depends on this
  115. library as it uses <command>-lgcc_eh</command> within its build system.
  116. We can satisfy that dependency by creating a symlink to
  117. <filename class="libraryfile">libgcc.a</filename>, since that file will
  118. end up containing the objects normally contained in
  119. <filename class="libraryfile">libgcc_eh.a</filename>.</para>
  120. <screen><userinput>ln -vs libgcc.a `gcc -print-libgcc-file-name | \
  121. sed 's/libgcc/&amp;_eh/'`</userinput></screen>
  122. <para>As a finishing touch, create a symlink. Many programs and scripts
  123. run <command>cc</command> instead of <command>gcc</command>, which is
  124. used to keep programs generic and therefore usable on all kinds of UNIX
  125. systems where the GNU C compiler is not always installed. Running
  126. <command>cc</command> leaves the system administrator free to decide
  127. which C compiler to install:</para>
  128. <screen><userinput>ln -vs gcc /tools/bin/cc</userinput></screen>
  129. </sect2>
  130. <sect2 role="content">
  131. <title/>
  132. <para>Details on this package are located in
  133. <xref linkend="contents-gcc" role="."/></para>
  134. </sect2>
  135. </sect1>