gcc.xml 14 KB

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