gcc.xml 20 KB

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