gcc.xml 19 KB

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