gcc.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-system-gcc" role="wrap">
  8. <?dbhtml filename="gcc.html"?>
  9. <title>GCC-&gcc-version;</title>
  10. <indexterm zone="ch-system-gcc">
  11. <primary sortas="a-GCC">GCC</primary>
  12. </indexterm>
  13. <sect2 role="package">
  14. <title/>
  15. <para>The GCC package contains the GNU compiler collection, which includes
  16. the C and C++ compilers.</para>
  17. <segmentedlist>
  18. <segtitle>&buildtime;</segtitle>
  19. <segtitle>&diskspace;</segtitle>
  20. <seglistitem>
  21. <seg>&gcc-ch6-sbu;</seg>
  22. <seg>&gcc-ch6-du;</seg>
  23. </seglistitem>
  24. </segmentedlist>
  25. </sect2>
  26. <sect2 role="installation">
  27. <title>Installation of GCC</title>
  28. <para>Apply a <command>sed</command> substitution that will suppress the
  29. installation of <filename class="libraryfile">libiberty.a</filename>. The
  30. version of <filename class="libraryfile">libiberty.a</filename> provided by
  31. Binutils will be used instead:</para>
  32. <screen><userinput>sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
  33. <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
  34. built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
  35. Non-bootstrap builds omit this flag by default, so apply the following
  36. <command>sed</command> to use it in order to ensure consistent compiler
  37. builds.</para>
  38. <screen><userinput>sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen>
  39. <para>The <command>fixincludes</command> script is known to occasionally
  40. erroneously attempt to &quot;fix&quot; the system headers installed so far. As
  41. the headers installed by GCC-&gcc-version; and Glibc-&glibc-version; are known
  42. to not require fixing, issue the following command to prevent the
  43. <command>fixincludes</command> script from running:</para>
  44. <screen><userinput>sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
  45. <para>GCC provides a <command>gccbug</command> script which detects at
  46. compile time whether mktemp is present, and hardcodes the result in a test.
  47. This will cause the script to fall back to using less random names for
  48. temporary files. We will be installing mktemp later, so the following sed
  49. will simulate its presence.</para>
  50. <screen><userinput>sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in</userinput></screen>
  51. <para>The GCC documentation recommends building GCC outside of the source
  52. directory in a dedicated build directory:</para>
  53. <screen><userinput>mkdir -v ../gcc-build
  54. cd ../gcc-build</userinput></screen>
  55. <para>Prepare GCC for compilation:</para>
  56. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr \
  57. --libexecdir=/usr/lib --enable-shared \
  58. --enable-threads=posix --enable-__cxa_atexit \
  59. --enable-clocale=gnu --enable-languages=c,c++</userinput></screen>
  60. <para>Compile the package:</para>
  61. <screen><userinput>make</userinput></screen>
  62. <important>
  63. <para>In this section, the test suite for GCC is considered
  64. critical. Do not skip it under any circumstance.</para>
  65. </important>
  66. <para>Test the results, but do not stop at errors:</para>
  67. <screen><userinput>make -k check</userinput></screen>
  68. <para>Some of the errors are known issues and were noted in the
  69. previous chapter. The test suite notes from <xref
  70. linkend="ch-tools-gcc-pass2" role=","/> are still relevant here. Be sure to
  71. refer back to them as necessary.</para>
  72. <para>Install the package:</para>
  73. <screen><userinput>make install</userinput></screen>
  74. <para>Some packages expect the C preprocessor to be installed in the
  75. <filename class="directory">/lib</filename> directory.
  76. To support those packages, create this symlink:</para>
  77. <screen><userinput>ln -sv ../usr/bin/cpp /lib</userinput></screen>
  78. <para>Many packages use the name <command>cc</command> to call the C
  79. compiler. To satisfy those packages, create a symlink:</para>
  80. <screen><userinput>ln -sv gcc /usr/bin/cc</userinput></screen>
  81. <para>Now that our final toolchain is in place, it is important to again ensure
  82. that compiling and linking will work as expected. We do this by performing
  83. the same sanity checks as we did earlier in the chapter:</para>
  84. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  85. href="readjusting.xml"
  86. xpointer="xpointer(//*[@os='a'])"/>
  87. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  88. href="readjusting.xml"
  89. xpointer="xpointer(//*[@os='b'])"/>
  90. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  91. href="readjusting.xml"
  92. xpointer="xpointer(//*[@os='c'])"/>
  93. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  94. href="readjusting.xml"
  95. xpointer="xpointer(//*[@os='d'])"/>
  96. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  97. href="readjusting.xml"
  98. xpointer="xpointer(//*[@os='e'])"/>
  99. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  100. href="readjusting.xml"
  101. xpointer="xpointer(//*[@os='f'])"/>
  102. <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
  103. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
  104. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
  105. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  106. href="readjusting.xml"
  107. xpointer="xpointer(//*[@os='g'])"/>
  108. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  109. href="readjusting.xml"
  110. xpointer="xpointer(//*[@os='h'])"/>
  111. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  112. href="readjusting.xml"
  113. xpointer="xpointer(//*[@os='i'])"/>
  114. <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
  115. SEARCH_DIR("/usr/local/lib")
  116. SEARCH_DIR("/lib")
  117. SEARCH_DIR("/usr/lib");</computeroutput></screen>
  118. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  119. href="readjusting.xml"
  120. xpointer="xpointer(//*[@os='j'])"/>
  121. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  122. href="readjusting.xml"
  123. xpointer="xpointer(//*[@os='k'])"/>
  124. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  125. href="readjusting.xml"
  126. xpointer="xpointer(//*[@os='l'])"/>
  127. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  128. href="readjusting.xml"
  129. xpointer="xpointer(//*[@os='m'])"/>
  130. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  131. href="readjusting.xml"
  132. xpointer="xpointer(//*[@os='n'])"/>
  133. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  134. href="readjusting.xml"
  135. xpointer="xpointer(//*[@os='o'])"/>
  136. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  137. href="readjusting.xml"
  138. xpointer="xpointer(//*[@os='p'])"/>
  139. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  140. href="readjusting.xml"
  141. xpointer="xpointer(//*[@os='q'])"/>
  142. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  143. href="readjusting.xml"
  144. xpointer="xpointer(//*[@os='r'])"/>
  145. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  146. href="readjusting.xml"
  147. xpointer="xpointer(//*[@os='s'])"/>
  148. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  149. href="readjusting.xml"
  150. xpointer="xpointer(//*[@os='t'])"/>
  151. </sect2>
  152. <sect2 id="contents-gcc" role="content">
  153. <title>Contents of GCC</title>
  154. <segmentedlist>
  155. <segtitle>Installed programs</segtitle>
  156. <segtitle>Installed libraries</segtitle>
  157. <seglistitem>
  158. <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
  159. <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libstdc++.{a,so}, and
  160. libsupc++.a</seg>
  161. </seglistitem>
  162. </segmentedlist>
  163. <variablelist>
  164. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  165. <?dbfo list-presentation="list"?>
  166. <?dbhtml list-presentation="table"?>
  167. <varlistentry id="cc">
  168. <term><command>cc</command></term>
  169. <listitem>
  170. <para>The C compiler</para>
  171. <indexterm zone="ch-system-gcc cc">
  172. <primary sortas="b-cc">cc</primary>
  173. </indexterm>
  174. </listitem>
  175. </varlistentry>
  176. <varlistentry id="cpp">
  177. <term><command>cpp</command></term>
  178. <listitem>
  179. <para>The C preprocessor; it is used by the compiler to expand the
  180. #include, #define, and similar statements in the source files</para>
  181. <indexterm zone="ch-system-gcc cpp">
  182. <primary sortas="b-cpp">cpp</primary>
  183. </indexterm>
  184. </listitem>
  185. </varlistentry>
  186. <varlistentry id="c">
  187. <term><command>c++</command></term>
  188. <listitem>
  189. <para>The C++ compiler</para>
  190. <indexterm zone="ch-system-gcc c">
  191. <primary sortas="b-c++">c++</primary>
  192. </indexterm>
  193. </listitem>
  194. </varlistentry>
  195. <varlistentry id="g">
  196. <term><command>g++</command></term>
  197. <listitem>
  198. <para>The C++ compiler</para>
  199. <indexterm zone="ch-system-gcc g">
  200. <primary sortas="b-g++">g++</primary>
  201. </indexterm>
  202. </listitem>
  203. </varlistentry>
  204. <varlistentry id="gcc">
  205. <term><command>gcc</command></term>
  206. <listitem>
  207. <para>The C compiler</para>
  208. <indexterm zone="ch-system-gcc gcc">
  209. <primary sortas="b-gcc">gcc</primary>
  210. </indexterm>
  211. </listitem>
  212. </varlistentry>
  213. <varlistentry id="gccbug">
  214. <term><command>gccbug</command></term>
  215. <listitem>
  216. <para>A shell script used to help create useful bug reports</para>
  217. <indexterm zone="ch-system-gcc gccbug">
  218. <primary sortas="b-gccbug">gccbug</primary>
  219. </indexterm>
  220. </listitem>
  221. </varlistentry>
  222. <varlistentry id="gcov">
  223. <term><command>gcov</command></term>
  224. <listitem>
  225. <para>A coverage testing tool; it is used to analyze programs to
  226. determine where optimizations will have the most effect</para>
  227. <indexterm zone="ch-system-gcc gcov">
  228. <primary sortas="b-gcov">gcov</primary>
  229. </indexterm>
  230. </listitem>
  231. </varlistentry>
  232. <varlistentry id="libgcc">
  233. <term><filename class="libraryfile">libgcc</filename></term>
  234. <listitem>
  235. <para>Contains run-time support for <command>gcc</command></para>
  236. <indexterm zone="ch-system-gcc libgcc">
  237. <primary sortas="c-libgcc*">libgcc*</primary>
  238. </indexterm>
  239. </listitem>
  240. </varlistentry>
  241. <varlistentry id="libstdc">
  242. <term><filename class="libraryfile">libstdc++</filename></term>
  243. <listitem>
  244. <para>The standard C++ library</para>
  245. <indexterm zone="ch-system-gcc libstdc">
  246. <primary sortas="c-libstdc++">libstdc++</primary>
  247. </indexterm>
  248. </listitem>
  249. </varlistentry>
  250. <varlistentry id="libsupc">
  251. <term><filename class="libraryfile">libsupc++</filename></term>
  252. <listitem>
  253. <para>Provides supporting routines for the C++ programming
  254. language</para>
  255. <indexterm zone="ch-system-gcc libsupc">
  256. <primary sortas="c-libsupc++">libsupc++</primary>
  257. </indexterm>
  258. </listitem>
  259. </varlistentry>
  260. </variablelist>
  261. </sect2>
  262. </sect1>