gcc.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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>As in <xref linkend="ch-tools-gcc-pass2"/>, apply the following
  39. <command>sed</command> to force the build to use the
  40. <option>-fomit-frame-pointer</option> compiler flag in order to ensure
  41. consistent compiler builds:</para>
  42. <screen><userinput remap="pre">case `uname -m` in
  43. i?86) sed -i 's/^T_CFLAGS =$/&amp; -fomit-frame-pointer/' \
  44. gcc/Makefile.in ;;
  45. esac</userinput></screen>
  46. <para>The <command>fixincludes</command> script is known to occasionally
  47. erroneously attempt to &quot;fix&quot; the system headers installed so far.
  48. As the headers up to this point are known to not require fixing,
  49. issue the following command to prevent the <command>fixincludes</command>
  50. script from running:</para>
  51. <screen><userinput remap="pre">sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in</userinput></screen>
  52. <para>Apply a <command>sed</command> substitution to prevent a testsuite
  53. error:</para>
  54. <screen><userinput remap="pre">sed -i 's/getline/get_line/' libiberty/testsuite/test-demangle.c</userinput></screen>
  55. <para>The GCC documentation recommends building GCC outside of the source
  56. directory in a dedicated build directory:</para>
  57. <screen><userinput remap="pre">mkdir -v ../gcc-build
  58. cd ../gcc-build</userinput></screen>
  59. <para>Prepare GCC for compilation:</para>
  60. <screen><userinput remap="configure">../gcc-&gcc-version;/configure --prefix=/usr \
  61. --libexecdir=/usr/lib --enable-shared \
  62. --enable-threads=posix --enable-__cxa_atexit \
  63. --enable-clocale=gnu --enable-languages=c,c++ \
  64. --disable-multilib --disable-bootstrap</userinput></screen>
  65. <para>Note that for other languages, there are some prerequisites that
  66. are not available. See the BLFS Book for instructions on how to
  67. build all the GCC supported languages.</para>
  68. <para>Compile the package:</para>
  69. <screen><userinput remap="make">make</userinput></screen>
  70. <important>
  71. <para>In this section, the test suite for GCC is considered
  72. critical. Do not skip it under any circumstance.</para>
  73. </important>
  74. <para>Test the results, but do not stop at errors:</para>
  75. <screen><userinput remap="test">make -k check</userinput></screen>
  76. <para>To receive a summary of the test suite results, run:</para>
  77. <screen><userinput remap="test">../gcc-&gcc-version;/contrib/test_summary</userinput></screen>
  78. <para>For only the summaries, pipe the output through
  79. <userinput>grep -A7 Summ</userinput>.</para>
  80. <para>Results can be compared with those located at <ulink
  81. url="&test-results;"/> and <ulink url="http://gcc.gnu.org/ml/gcc-testresults/"/>.</para>
  82. <para>A few unexpected failures cannot always be avoided. The GCC developers
  83. are usually aware of these issues, but have not resolved them yet. In
  84. particular, the <filename class="libraryfile">libmudflap</filename> tests
  85. are known be particularly problematic as a result of a bug in GCC
  86. (<ulink url="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20003"/>).
  87. Unless the test results are vastly different from those at the above URL,
  88. it is safe to continue.</para>
  89. <para>Install the package:</para>
  90. <screen><userinput remap="install">make install</userinput></screen>
  91. <para>Some packages expect the C preprocessor to be installed in the
  92. <filename class="directory">/lib</filename> directory.
  93. To support those packages, create this symlink:</para>
  94. <screen><userinput remap="install">ln -sv ../usr/bin/cpp /lib</userinput></screen>
  95. <para>Many packages use the name <command>cc</command> to call the C
  96. compiler. To satisfy those packages, create a symlink:</para>
  97. <screen><userinput remap="install">ln -sv gcc /usr/bin/cc</userinput></screen>
  98. <para>Now that our final toolchain is in place, it is important to again ensure
  99. that compiling and linking will work as expected. We do this by performing
  100. the same sanity checks as we did earlier in the chapter:</para>
  101. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  102. href="readjusting.xml"
  103. xpointer="xpointer(//*[@os='a'])"/>
  104. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  105. href="readjusting.xml"
  106. xpointer="xpointer(//*[@os='b'])"/>
  107. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  108. href="readjusting.xml"
  109. xpointer="xpointer(//*[@os='c'])"/>
  110. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  111. href="readjusting.xml"
  112. xpointer="xpointer(//*[@os='d'])"/>
  113. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  114. href="readjusting.xml"
  115. xpointer="xpointer(//*[@os='e'])"/>
  116. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  117. href="readjusting.xml"
  118. xpointer="xpointer(//*[@os='f'])"/>
  119. <screen><computeroutput>/usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crt1.o succeeded
  120. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crti.o succeeded
  121. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/../../../crtn.o succeeded</computeroutput></screen>
  122. <para>Depending on your machine architecture, the above may differ slightly,
  123. the difference usually being the name of the directory
  124. after <filename class="directory">/usr/lib/gcc</filename>. If your machine is
  125. a 64-bit system, you may also see a directory named <filename class="directory">lib64</filename>
  126. towards the end of the string. The important thing to
  127. look for here is that <command>gcc</command> has found all three
  128. <filename>crt*.o</filename> files under the
  129. <filename class="directory">/usr/lib</filename> directory.</para>
  130. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  131. href="readjusting.xml"
  132. xpointer="xpointer(//*[@os='g'])"/>
  133. <screen><userinput>grep -B4 '^ /usr/include' dummy.log</userinput></screen>
  134. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  135. href="readjusting.xml"
  136. xpointer="xpointer(//*[@os='h'])"/>
  137. <screen><computeroutput>#include &lt;...&gt; search starts here:
  138. /usr/local/include
  139. /usr/lib/gcc/x86_64-unknown-linux-gnu/&gcc-version;/include
  140. /usr/lib/gcc/i686-pc-linux-gnu/&gcc-version;/include-fixed
  141. /usr/include</computeroutput></screen>
  142. <para>Again, note that the directory named after your target triplet may be
  143. different than the above, depending on your architecture.</para>
  144. <note><para>As of version 4.3.0, GCC now unconditionally installs the
  145. <filename>limits.h</filename> file into the private
  146. <filename class="directory">include-fixed</filename> directory, and that
  147. directory is required to be in place.</para></note>
  148. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  149. href="readjusting.xml"
  150. xpointer="xpointer(//*[@os='i'])"/>
  151. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  152. href="readjusting.xml"
  153. xpointer="xpointer(//*[@os='j'])"/>
  154. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  155. href="readjusting.xml"
  156. xpointer="xpointer(//*[@os='k'])"/>
  157. <screen><computeroutput>SEARCH_DIR("/usr/i686-pc-linux-gnu/lib")
  158. SEARCH_DIR("/usr/local/lib")
  159. SEARCH_DIR("/lib")
  160. SEARCH_DIR("/usr/lib");</computeroutput></screen>
  161. <para>A 64-bit system may see a few more directories. For example, here
  162. is the output from an x86_64 machine:</para>
  163. <screen><computeroutput>SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib64")
  164. SEARCH_DIR("/usr/local/lib64")
  165. SEARCH_DIR("/lib64")
  166. SEARCH_DIR("/usr/lib64")
  167. SEARCH_DIR("/usr/x86_64-unknown-linux-gnu/lib")
  168. SEARCH_DIR("/usr/local/lib")
  169. SEARCH_DIR("/lib")
  170. SEARCH_DIR("/usr/lib");</computeroutput></screen>
  171. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  172. href="readjusting.xml"
  173. xpointer="xpointer(//*[@os='l'])"/>
  174. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  175. href="readjusting.xml"
  176. xpointer="xpointer(//*[@os='m'])"/>
  177. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  178. href="readjusting.xml"
  179. xpointer="xpointer(//*[@os='n'])"/>
  180. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  181. href="readjusting.xml"
  182. xpointer="xpointer(//*[@os='o'])"/>
  183. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  184. href="readjusting.xml"
  185. xpointer="xpointer(//*[@os='p'])"/>
  186. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  187. href="readjusting.xml"
  188. xpointer="xpointer(//*[@os='q'])"/>
  189. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  190. href="readjusting.xml"
  191. xpointer="xpointer(//*[@os='r'])"/>
  192. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  193. href="readjusting.xml"
  194. xpointer="xpointer(//*[@os='s'])"/>
  195. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  196. href="readjusting.xml"
  197. xpointer="xpointer(//*[@os='t'])"/>
  198. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  199. href="readjusting.xml"
  200. xpointer="xpointer(//*[@os='u'])"/>
  201. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  202. href="readjusting.xml"
  203. xpointer="xpointer(//*[@os='v'])"/>
  204. </sect2>
  205. <sect2 id="contents-gcc" role="content">
  206. <title>Contents of GCC</title>
  207. <segmentedlist>
  208. <segtitle>Installed programs</segtitle>
  209. <segtitle>Installed libraries</segtitle>
  210. <seglistitem>
  211. <seg>c++, cc (link to gcc), cpp, g++, gcc, gccbug, and gcov</seg>
  212. <seg>libgcc.a, libgcc_eh.a, libgcc_s.so, libgcov.a, libgomp.{a,so},
  213. libmudflap.{a,so}, libmudflapth.{a,so}, libssp.{a,so},
  214. libssp_nonshared.a, libstdc++.{a,so} and libsupc++.a</seg>
  215. </seglistitem>
  216. </segmentedlist>
  217. <variablelist>
  218. <bridgehead renderas="sect3">Short Descriptions</bridgehead>
  219. <?dbfo list-presentation="list"?>
  220. <?dbhtml list-presentation="table"?>
  221. <varlistentry id="c">
  222. <term><command>c++</command></term>
  223. <listitem>
  224. <para>The C++ compiler</para>
  225. <indexterm zone="ch-system-gcc c">
  226. <primary sortas="b-c++">c++</primary>
  227. </indexterm>
  228. </listitem>
  229. </varlistentry>
  230. <varlistentry id="cc">
  231. <term><command>cc</command></term>
  232. <listitem>
  233. <para>The C compiler</para>
  234. <indexterm zone="ch-system-gcc cc">
  235. <primary sortas="b-cc">cc</primary>
  236. </indexterm>
  237. </listitem>
  238. </varlistentry>
  239. <varlistentry id="cpp">
  240. <term><command>cpp</command></term>
  241. <listitem>
  242. <para>The C preprocessor; it is used by the compiler to expand the
  243. #include, #define, and similar statements in the source files</para>
  244. <indexterm zone="ch-system-gcc cpp">
  245. <primary sortas="b-cpp">cpp</primary>
  246. </indexterm>
  247. </listitem>
  248. </varlistentry>
  249. <varlistentry id="g">
  250. <term><command>g++</command></term>
  251. <listitem>
  252. <para>The C++ compiler</para>
  253. <indexterm zone="ch-system-gcc g">
  254. <primary sortas="b-g++">g++</primary>
  255. </indexterm>
  256. </listitem>
  257. </varlistentry>
  258. <varlistentry id="gcc">
  259. <term><command>gcc</command></term>
  260. <listitem>
  261. <para>The C compiler</para>
  262. <indexterm zone="ch-system-gcc gcc">
  263. <primary sortas="b-gcc">gcc</primary>
  264. </indexterm>
  265. </listitem>
  266. </varlistentry>
  267. <varlistentry id="gccbug">
  268. <term><command>gccbug</command></term>
  269. <listitem>
  270. <para>A shell script used to help create useful bug reports</para>
  271. <indexterm zone="ch-system-gcc gccbug">
  272. <primary sortas="b-gccbug">gccbug</primary>
  273. </indexterm>
  274. </listitem>
  275. </varlistentry>
  276. <varlistentry id="gcov">
  277. <term><command>gcov</command></term>
  278. <listitem>
  279. <para>A coverage testing tool; it is used to analyze programs to
  280. determine where optimizations will have the most effect</para>
  281. <indexterm zone="ch-system-gcc gcov">
  282. <primary sortas="b-gcov">gcov</primary>
  283. </indexterm>
  284. </listitem>
  285. </varlistentry>
  286. <varlistentry id="libgcc">
  287. <term><filename class="libraryfile">libgcc</filename></term>
  288. <listitem>
  289. <para>Contains run-time support for <command>gcc</command></para>
  290. <indexterm zone="ch-system-gcc libgcc">
  291. <primary sortas="c-libgcc*">libgcc*</primary>
  292. </indexterm>
  293. </listitem>
  294. </varlistentry>
  295. <varlistentry id="libgcov">
  296. <term><filename class="libraryfile">libgcov</filename></term>
  297. <listitem>
  298. <para>This library is linked in to a program when GCC is instructed
  299. to enable profiling</para>
  300. <indexterm zone="ch-system-gcc libgcov">
  301. <primary sortas="c-libgcov">libgcov</primary>
  302. </indexterm>
  303. </listitem>
  304. </varlistentry>
  305. <varlistentry id="libgomp">
  306. <term><filename class="libraryfile">libgomp</filename></term>
  307. <listitem>
  308. <para>GNU implementation of the OpenMP API for multi-platform
  309. shared-memory parallel programming in C/C++ and Fortran</para>
  310. <indexterm zone="ch-system-gcc libgomp">
  311. <primary sortas="c-libgomp">libgomp</primary>
  312. </indexterm>
  313. </listitem>
  314. </varlistentry>
  315. <varlistentry id="libmudflap">
  316. <term><filename class="libraryfile">libmudflap</filename></term>
  317. <listitem>
  318. <para>Contains routines that support GCC's bounds checking
  319. functionality</para>
  320. <indexterm zone="ch-system-gcc libmudflap">
  321. <primary sortas="c-libmudflap*">libmudflap*</primary>
  322. </indexterm>
  323. </listitem>
  324. </varlistentry>
  325. <varlistentry id="libssp">
  326. <term><filename class="libraryfile">libssp</filename></term>
  327. <listitem>
  328. <para>Contains routines supporting GCC's stack-smashing protection
  329. functionality</para>
  330. <indexterm zone="ch-system-gcc libssp">
  331. <primary sortas="c-libssp*">libssp*</primary>
  332. </indexterm>
  333. </listitem>
  334. </varlistentry>
  335. <varlistentry id="libstdc">
  336. <term><filename class="libraryfile">libstdc++</filename></term>
  337. <listitem>
  338. <para>The standard C++ library</para>
  339. <indexterm zone="ch-system-gcc libstdc">
  340. <primary sortas="c-libstdc++">libstdc++</primary>
  341. </indexterm>
  342. </listitem>
  343. </varlistentry>
  344. <varlistentry id="libsupc">
  345. <term><filename class="libraryfile">libsupc++</filename></term>
  346. <listitem>
  347. <para>Provides supporting routines for the C++ programming
  348. language</para>
  349. <indexterm zone="ch-system-gcc libsupc">
  350. <primary sortas="c-libsupc++">libsupc++</primary>
  351. </indexterm>
  352. </listitem>
  353. </varlistentry>
  354. </variablelist>
  355. </sect2>
  356. </sect1>