gcc.xml 19 KB

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