gcc.xml 15 KB

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