gcc.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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. <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>To receive a summary of the test suite results, run:</para>
  69. <screen><userinput>../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  70. <para>For only the summaries, pipe the output through
  71. <userinput>grep -A7 Summ</userinput>.</para>
  72. <para>Results can be compared with those located at <ulink
  73. url="&test-results;"/>.</para>
  74. <para>A few unexpected failures cannot always be avoided. The GCC developers
  75. are usually aware of these issues, but have not resolved them yet. In
  76. particular, the <filename class="libraryfile">libmudflap</filename> tests
  77. are known be particularly problematic as a result of a bug in GCC
  78. (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
  79. Unless the test results are vastly different from those at the above URL,
  80. it is safe to continue.</para>
  81. <para>Install the package:</para>
  82. <screen><userinput>make install</userinput></screen>
  83. <para>Some packages expect the C preprocessor to be installed in the
  84. <filename class="directory">/lib</filename> directory.
  85. To support those packages, create this symlink:</para>
  86. <screen><userinput>ln -sv ../usr/bin/cpp /lib</userinput></screen>
  87. <para>Many packages use the name <command>cc</command> to call the C
  88. compiler. To satisfy those packages, create a symlink:</para>
  89. <screen><userinput>ln -sv gcc /usr/bin/cc</userinput></screen>
  90. <para>Now that our final toolchain is in place, it is important to again ensure
  91. that compiling and linking will work as expected. We do this by performing
  92. the same sanity checks as we did earlier in the chapter:</para>
  93. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  94. href="readjusting.xml"
  95. xpointer="xpointer(//*[@os='a'])"/>
  96. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  97. href="readjusting.xml"
  98. xpointer="xpointer(//*[@os='b'])"/>
  99. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  100. href="readjusting.xml"
  101. xpointer="xpointer(//*[@os='c'])"/>
  102. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  103. href="readjusting.xml"
  104. xpointer="xpointer(//*[@os='d'])"/>
  105. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  106. href="readjusting.xml"
  107. xpointer="xpointer(//*[@os='e'])"/>
  108. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  109. href="readjusting.xml"
  110. xpointer="xpointer(//*[@os='f'])"/>
  111. <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
  112. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
  113. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
  114. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  115. href="readjusting.xml"
  116. xpointer="xpointer(//*[@os='g'])"/>
  117. <screen><userinput>grep -B3 '^ /usr/include' dummy.log</userinput></screen>
  118. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  119. href="readjusting.xml"
  120. xpointer="xpointer(//*[@os='h'])"/>
  121. <screen><computeroutput>#include &lt;...&gt; search starts here:
  122. /usr/local/include
  123. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include
  124. /usr/include</computeroutput></screen>
  125. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  126. href="readjusting.xml"
  127. xpointer="xpointer(//*[@os='i'])"/>
  128. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  129. href="readjusting.xml"
  130. xpointer="xpointer(//*[@os='j'])"/>
  131. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  132. href="readjusting.xml"
  133. xpointer="xpointer(//*[@os='k'])"/>
  134. <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
  135. SEARCH_DIR("/usr/local/lib")
  136. SEARCH_DIR("/lib")
  137. SEARCH_DIR("/usr/lib");</computeroutput></screen>
  138. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  139. href="readjusting.xml"
  140. xpointer="xpointer(//*[@os='l'])"/>
  141. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  142. href="readjusting.xml"
  143. xpointer="xpointer(//*[@os='m'])"/>
  144. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  145. href="readjusting.xml"
  146. xpointer="xpointer(//*[@os='n'])"/>
  147. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  148. href="readjusting.xml"
  149. xpointer="xpointer(//*[@os='o'])"/>
  150. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  151. href="readjusting.xml"
  152. xpointer="xpointer(//*[@os='p'])"/>
  153. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  154. href="readjusting.xml"
  155. xpointer="xpointer(//*[@os='q'])"/>
  156. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  157. href="readjusting.xml"
  158. xpointer="xpointer(//*[@os='r'])"/>
  159. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  160. href="readjusting.xml"
  161. xpointer="xpointer(//*[@os='s'])"/>
  162. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  163. href="readjusting.xml"
  164. xpointer="xpointer(//*[@os='t'])"/>
  165. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  166. href="readjusting.xml"
  167. xpointer="xpointer(//*[@os='u'])"/>
  168. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  169. href="readjusting.xml"
  170. xpointer="xpointer(//*[@os='v'])"/>
  171. </sect2>
  172. <sect2 id="contents-gcc" role="content">
  173. <title>Contents of GCC</title>
  174. <segmentedlist>
  175. <segtitle>Installed programs</segtitle>
  176. <segtitle>Installed libraries</segtitle>
  177. <seglistitem>
  178. <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
  179. <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libmudflap.{a,so},
  180. libssp.{a,so}libstdc++.{a,so}, and libsupc++.a</seg>
  181. </seglistitem>
  182. </segmentedlist>
  183. <variablelist>
  184. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  185. <?dbfo list-presentation="list"?>
  186. <?dbhtml list-presentation="table"?>
  187. <varlistentry id="c">
  188. <term><command>c++</command></term>
  189. <listitem>
  190. <para>The C++ compiler</para>
  191. <indexterm zone="ch-system-gcc c">
  192. <primary sortas="b-c++">c++</primary>
  193. </indexterm>
  194. </listitem>
  195. </varlistentry>
  196. <varlistentry id="cc">
  197. <term><command>cc</command></term>
  198. <listitem>
  199. <para>The C compiler</para>
  200. <indexterm zone="ch-system-gcc cc">
  201. <primary sortas="b-cc">cc</primary>
  202. </indexterm>
  203. </listitem>
  204. </varlistentry>
  205. <varlistentry id="cpp">
  206. <term><command>cpp</command></term>
  207. <listitem>
  208. <para>The C preprocessor; it is used by the compiler to expand the
  209. #include, #define, and similar statements in the source files</para>
  210. <indexterm zone="ch-system-gcc cpp">
  211. <primary sortas="b-cpp">cpp</primary>
  212. </indexterm>
  213. </listitem>
  214. </varlistentry>
  215. <varlistentry id="g">
  216. <term><command>g++</command></term>
  217. <listitem>
  218. <para>The C++ compiler</para>
  219. <indexterm zone="ch-system-gcc g">
  220. <primary sortas="b-g++">g++</primary>
  221. </indexterm>
  222. </listitem>
  223. </varlistentry>
  224. <varlistentry id="gcc">
  225. <term><command>gcc</command></term>
  226. <listitem>
  227. <para>The C compiler</para>
  228. <indexterm zone="ch-system-gcc gcc">
  229. <primary sortas="b-gcc">gcc</primary>
  230. </indexterm>
  231. </listitem>
  232. </varlistentry>
  233. <varlistentry id="gccbug">
  234. <term><command>gccbug</command></term>
  235. <listitem>
  236. <para>A shell script used to help create useful bug reports</para>
  237. <indexterm zone="ch-system-gcc gccbug">
  238. <primary sortas="b-gccbug">gccbug</primary>
  239. </indexterm>
  240. </listitem>
  241. </varlistentry>
  242. <varlistentry id="gcov">
  243. <term><command>gcov</command></term>
  244. <listitem>
  245. <para>A coverage testing tool; it is used to analyze programs to
  246. determine where optimizations will have the most effect</para>
  247. <indexterm zone="ch-system-gcc gcov">
  248. <primary sortas="b-gcov">gcov</primary>
  249. </indexterm>
  250. </listitem>
  251. </varlistentry>
  252. <varlistentry id="libgcc">
  253. <term><filename class="libraryfile">libgcc</filename></term>
  254. <listitem>
  255. <para>Contains run-time support for <command>gcc</command></para>
  256. <indexterm zone="ch-system-gcc libgcc">
  257. <primary sortas="c-libgcc*">libgcc*</primary>
  258. </indexterm>
  259. </listitem>
  260. </varlistentry>
  261. <varlistentry id="libmudflap">
  262. <term><filename class="libraryfile">libmudflap</filename></term>
  263. <listitem>
  264. <para>Contains routines that support GCC's bounds checking
  265. functionality</para>
  266. <indexterm zone="ch-system-gcc libmudflap">
  267. <primary sortas="c-libmudflap*">libmudflap*</primary>
  268. </indexterm>
  269. </listitem>
  270. </varlistentry>
  271. <varlistentry id="libssp">
  272. <term><filename class="libraryfile">libssp</filename></term>
  273. <listitem>
  274. <para>Contains routines supporting GCC's stack-smashing protection
  275. functionality</para>
  276. <indexterm zone="ch-system-gcc libssp">
  277. <primary sortas="c-libssp*">libssp*</primary>
  278. </indexterm>
  279. </listitem>
  280. </varlistentry>
  281. <varlistentry id="libstdc">
  282. <term><filename class="libraryfile">libstdc++</filename></term>
  283. <listitem>
  284. <para>The standard C++ library</para>
  285. <indexterm zone="ch-system-gcc libstdc">
  286. <primary sortas="c-libstdc++">libstdc++</primary>
  287. </indexterm>
  288. </listitem>
  289. </varlistentry>
  290. <varlistentry id="libsupc">
  291. <term><filename class="libraryfile">libsupc++</filename></term>
  292. <listitem>
  293. <para>Provides supporting routines for the C++ programming
  294. language</para>
  295. <indexterm zone="ch-system-gcc libsupc">
  296. <primary sortas="c-libsupc++">libsupc++</primary>
  297. </indexterm>
  298. </listitem>
  299. </varlistentry>
  300. </variablelist>
  301. </sect2>
  302. </sect1>