gcc.xml 14 KB

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