gcc-pass1.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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>Continue with compiling the package:</para>
  98. <screen><userinput>make</userinput></screen>
  99. <para>Compilation is now complete. At this point, the test suite would
  100. normally be run, but, as mentioned before, the test suite framework is
  101. not in place yet. The benefits of running the tests at this point
  102. are minimal since the programs from this first pass will soon be
  103. replaced.</para>
  104. <para>Install the package:</para>
  105. <screen><userinput>make install</userinput></screen>
  106. <para>Using <command>--disable-shared</command> means that the file
  107. <filename class="libraryfile">libgcc_eh.a</filename>
  108. isn't created and installed. The next package, Glibc, depends on this
  109. library as it uses <command>-lgcc_eh</command> within its build system.
  110. We can satisfy that dependency by creating a symlink to
  111. <filename class="libraryfile">libgcc.a</filename>, since that file will
  112. end up containing the objects normally contained in
  113. <filename class="libraryfile">libgcc_eh.a</filename>.</para>
  114. <screen><userinput>ln -vs libgcc.a `gcc -print-libgcc-file-name | \
  115. sed 's/libgcc/&amp;_eh/'`</userinput></screen>
  116. <para>As a finishing touch, create a symlink. Many programs and scripts
  117. run <command>cc</command> instead of <command>gcc</command>, which is
  118. used to keep programs generic and therefore usable on all kinds of UNIX
  119. systems where the GNU C compiler is not always installed. Running
  120. <command>cc</command> leaves the system administrator free to decide
  121. which C compiler to install:</para>
  122. <screen><userinput>ln -vs gcc /tools/bin/cc</userinput></screen>
  123. </sect2>
  124. <sect2 role="content">
  125. <title/>
  126. <para>Details on this package are located in
  127. <xref linkend="contents-gcc" role="."/></para>
  128. </sect2>
  129. </sect1>