gcc.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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-system-gcc" role="wrap">
  8. <?dbhtml filename="gcc.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;</title>
  15. <indexterm zone="ch-system-gcc">
  16. <primary sortas="a-GCC">GCC</primary>
  17. </indexterm>
  18. <sect2 role="package">
  19. <title/>
  20. <para>The GCC package contains the GNU compiler collection, which includes
  21. the C and C++ compilers.</para>
  22. <segmentedlist>
  23. <segtitle>&buildtime;</segtitle>
  24. <segtitle>&diskspace;</segtitle>
  25. <seglistitem>
  26. <seg>&gcc-ch6-sbu;</seg>
  27. <seg>&gcc-ch6-du;</seg>
  28. </seglistitem>
  29. </segmentedlist>
  30. </sect2>
  31. <sect2 role="installation">
  32. <title>Installation of GCC</title>
  33. <para>Apply a <command>sed</command> substitution that will suppress the
  34. installation of <filename class="libraryfile">libiberty.a</filename>. The
  35. version of <filename class="libraryfile">libiberty.a</filename> provided by
  36. Binutils will be used instead:</para>
  37. <screen><userinput remap="pre">sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
  38. <para>The bootstrap build performed in <xref linkend="ch-tools-gcc-pass1"/>
  39. built GCC with the <option>-fomit-frame-pointer</option> compiler flag.
  40. Non-bootstrap builds omit this flag by default, so apply the following
  41. <command>sed</command> to use it in order to ensure consistent compiler
  42. builds:</para>
  43. <screen><userinput remap="pre">sed -i 's/^XCFLAGS =$/&amp; -fomit-frame-pointer/' gcc/Makefile.in</userinput></screen>
  44. <para>The <command>fixincludes</command> script is known to occasionally
  45. erroneously attempt to &quot;fix&quot; the system headers installed so far. As
  46. the headers installed by GCC-&gcc-version; and Glibc-&glibc-version; are known
  47. to not require fixing, issue the following command to prevent the
  48. <command>fixincludes</command> script from running:</para>
  49. <screen><userinput remap="pre">sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
  50. <para>GCC provides a <command>gccbug</command> script which detects at
  51. compile time whether mktemp is present, and hardcodes the result in a test.
  52. This will cause the script to fall back to using less random names for
  53. temporary files. We will be installing mktemp later, so the following sed
  54. will simulate its presence:</para>
  55. <screen><userinput remap="pre">sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in</userinput></screen>
  56. <para>The GCC documentation recommends building GCC outside of the source
  57. directory in a dedicated build directory:</para>
  58. <screen><userinput remap="pre">mkdir -v ../gcc-build
  59. cd ../gcc-build</userinput></screen>
  60. <para>Prepare GCC for compilation:</para>
  61. <screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
  62. --libexecdir=/usr/lib --enable-shared \
  63. --enable-threads=posix --enable-__cxa_atexit \
  64. --enable-clocale=gnu --enable-languages=c,c++ \
  65. --disable-bootstrap</userinput></screen>
  66. <para>Compile the package:</para>
  67. <screen><userinput remap="make">make</userinput></screen>
  68. <important>
  69. <para>In this section, the test suite for GCC is considered
  70. critical. Do not skip it under any circumstance.</para>
  71. </important>
  72. <para>Test the results, but do not stop at errors:</para>
  73. <screen><userinput remap="test">make -k check</userinput></screen>
  74. <para>To receive a summary of the test suite results, run:</para>
  75. <screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  76. <para>For only the summaries, pipe the output through
  77. <userinput>grep -A7 Summ</userinput>.</para>
  78. <para>Results can be compared with those located at <ulink
  79. url="&test-results;"/>.</para>
  80. <para>A few unexpected failures cannot always be avoided. The GCC developers
  81. are usually aware of these issues, but have not resolved them yet. In
  82. particular, the <filename class="libraryfile">libmudflap</filename> tests
  83. are known be particularly problematic as a result of a bug in GCC
  84. (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
  85. Unless the test results are vastly different from those at the above URL,
  86. it is safe to continue.</para>
  87. <para>Install the package:</para>
  88. <screen><userinput remap="install">make install</userinput></screen>
  89. <para>Some packages expect the C preprocessor to be installed in the
  90. <filename class="directory">/lib</filename> directory.
  91. To support those packages, create this symlink:</para>
  92. <screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
  93. <para>Many packages use the name <command>cc</command> to call the C
  94. compiler. To satisfy those packages, create a symlink:</para>
  95. <screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
  96. <para>Now that our final toolchain is in place, it is important to again ensure
  97. that compiling and linking will work as expected. We do this by performing
  98. the same sanity checks as we did earlier in the chapter:</para>
  99. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  100. href="readjusting.xml"
  101. xpointer="xpointer(//*[@os='a'])"/>
  102. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  103. href="readjusting.xml"
  104. xpointer="xpointer(//*[@os='b'])"/>
  105. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  106. href="readjusting.xml"
  107. xpointer="xpointer(//*[@os='c'])"/>
  108. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  109. href="readjusting.xml"
  110. xpointer="xpointer(//*[@os='d'])"/>
  111. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  112. href="readjusting.xml"
  113. xpointer="xpointer(//*[@os='e'])"/>
  114. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  115. href="readjusting.xml"
  116. xpointer="xpointer(//*[@os='f'])"/>
  117. <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
  118. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
  119. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
  120. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  121. href="readjusting.xml"
  122. xpointer="xpointer(//*[@os='g'])"/>
  123. <screen><userinput>grep -B3 '^ /usr/include' dummy.log</userinput></screen>
  124. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  125. href="readjusting.xml"
  126. xpointer="xpointer(//*[@os='h'])"/>
  127. <screen><computeroutput>#include &lt;...&gt; search starts here:
  128. /usr/local/include
  129. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
  130. /usr/include</computeroutput></screen>
  131. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  132. href="readjusting.xml"
  133. xpointer="xpointer(//*[@os='i'])"/>
  134. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  135. href="readjusting.xml"
  136. xpointer="xpointer(//*[@os='j'])"/>
  137. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  138. href="readjusting.xml"
  139. xpointer="xpointer(//*[@os='k'])"/>
  140. <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
  141. SEARCH_DIR("/usr/local/lib")
  142. SEARCH_DIR("/lib")
  143. SEARCH_DIR("/usr/lib");</computeroutput></screen>
  144. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  145. href="readjusting.xml"
  146. xpointer="xpointer(//*[@os='l'])"/>
  147. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  148. href="readjusting.xml"
  149. xpointer="xpointer(//*[@os='m'])"/>
  150. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  151. href="readjusting.xml"
  152. xpointer="xpointer(//*[@os='n'])"/>
  153. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  154. href="readjusting.xml"
  155. xpointer="xpointer(//*[@os='o'])"/>
  156. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  157. href="readjusting.xml"
  158. xpointer="xpointer(//*[@os='p'])"/>
  159. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  160. href="readjusting.xml"
  161. xpointer="xpointer(//*[@os='q'])"/>
  162. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  163. href="readjusting.xml"
  164. xpointer="xpointer(//*[@os='r'])"/>
  165. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  166. href="readjusting.xml"
  167. xpointer="xpointer(//*[@os='s'])"/>
  168. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  169. href="readjusting.xml"
  170. xpointer="xpointer(//*[@os='t'])"/>
  171. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  172. href="readjusting.xml"
  173. xpointer="xpointer(//*[@os='u'])"/>
  174. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  175. href="readjusting.xml"
  176. xpointer="xpointer(//*[@os='v'])"/>
  177. </sect2>
  178. <sect2 id="contents-gcc" role="content">
  179. <title>Contents of GCC</title>
  180. <segmentedlist>
  181. <segtitle>Installed programs</segtitle>
  182. <segtitle>Installed libraries</segtitle>
  183. <seglistitem>
  184. <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
  185. <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libmudflap.{a,so},
  186. libssp.{a,so}, libstdc++.{a,so}, and libsupc++.a</seg>
  187. </seglistitem>
  188. </segmentedlist>
  189. <variablelist>
  190. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  191. <?dbfo list-presentation="list"?>
  192. <?dbhtml list-presentation="table"?>
  193. <varlistentry id="c">
  194. <term><command>c++</command></term>
  195. <listitem>
  196. <para>The C++ compiler</para>
  197. <indexterm zone="ch-system-gcc c">
  198. <primary sortas="b-c++">c++</primary>
  199. </indexterm>
  200. </listitem>
  201. </varlistentry>
  202. <varlistentry id="cc">
  203. <term><command>cc</command></term>
  204. <listitem>
  205. <para>The C compiler</para>
  206. <indexterm zone="ch-system-gcc cc">
  207. <primary sortas="b-cc">cc</primary>
  208. </indexterm>
  209. </listitem>
  210. </varlistentry>
  211. <varlistentry id="cpp">
  212. <term><command>cpp</command></term>
  213. <listitem>
  214. <para>The C preprocessor; it is used by the compiler to expand the
  215. #include, #define, and similar statements in the source files</para>
  216. <indexterm zone="ch-system-gcc cpp">
  217. <primary sortas="b-cpp">cpp</primary>
  218. </indexterm>
  219. </listitem>
  220. </varlistentry>
  221. <varlistentry id="g">
  222. <term><command>g++</command></term>
  223. <listitem>
  224. <para>The C++ compiler</para>
  225. <indexterm zone="ch-system-gcc g">
  226. <primary sortas="b-g++">g++</primary>
  227. </indexterm>
  228. </listitem>
  229. </varlistentry>
  230. <varlistentry id="gcc">
  231. <term><command>gcc</command></term>
  232. <listitem>
  233. <para>The C compiler</para>
  234. <indexterm zone="ch-system-gcc gcc">
  235. <primary sortas="b-gcc">gcc</primary>
  236. </indexterm>
  237. </listitem>
  238. </varlistentry>
  239. <varlistentry id="gccbug">
  240. <term><command>gccbug</command></term>
  241. <listitem>
  242. <para>A shell script used to help create useful bug reports</para>
  243. <indexterm zone="ch-system-gcc gccbug">
  244. <primary sortas="b-gccbug">gccbug</primary>
  245. </indexterm>
  246. </listitem>
  247. </varlistentry>
  248. <varlistentry id="gcov">
  249. <term><command>gcov</command></term>
  250. <listitem>
  251. <para>A coverage testing tool; it is used to analyze programs to
  252. determine where optimizations will have the most effect</para>
  253. <indexterm zone="ch-system-gcc gcov">
  254. <primary sortas="b-gcov">gcov</primary>
  255. </indexterm>
  256. </listitem>
  257. </varlistentry>
  258. <varlistentry id="libgcc">
  259. <term><filename class="libraryfile">libgcc</filename></term>
  260. <listitem>
  261. <para>Contains run-time support for <command>gcc</command></para>
  262. <indexterm zone="ch-system-gcc libgcc">
  263. <primary sortas="c-libgcc*">libgcc*</primary>
  264. </indexterm>
  265. </listitem>
  266. </varlistentry>
  267. <varlistentry id="libmudflap">
  268. <term><filename class="libraryfile">libmudflap</filename></term>
  269. <listitem>
  270. <para>Contains routines that support GCC's bounds checking
  271. functionality</para>
  272. <indexterm zone="ch-system-gcc libmudflap">
  273. <primary sortas="c-libmudflap*">libmudflap*</primary>
  274. </indexterm>
  275. </listitem>
  276. </varlistentry>
  277. <varlistentry id="libssp">
  278. <term><filename class="libraryfile">libssp</filename></term>
  279. <listitem>
  280. <para>Contains routines supporting GCC's stack-smashing protection
  281. functionality</para>
  282. <indexterm zone="ch-system-gcc libssp">
  283. <primary sortas="c-libssp*">libssp*</primary>
  284. </indexterm>
  285. </listitem>
  286. </varlistentry>
  287. <varlistentry id="libstdc">
  288. <term><filename class="libraryfile">libstdc++</filename></term>
  289. <listitem>
  290. <para>The standard C++ library</para>
  291. <indexterm zone="ch-system-gcc libstdc">
  292. <primary sortas="c-libstdc++">libstdc++</primary>
  293. </indexterm>
  294. </listitem>
  295. </varlistentry>
  296. <varlistentry id="libsupc">
  297. <term><filename class="libraryfile">libsupc++</filename></term>
  298. <listitem>
  299. <para>Provides supporting routines for the C++ programming
  300. language</para>
  301. <indexterm zone="ch-system-gcc libsupc">
  302. <primary sortas="c-libsupc++">libsupc++</primary>
  303. </indexterm>
  304. </listitem>
  305. </varlistentry>
  306. </variablelist>
  307. </sect2>
  308. </sect1>