gcc.xml 17 KB

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