gcc.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <sect1 id="ch-system-gcc" xreflabel="GCC">
  2. <title>Installing GCC-&gcc-version;</title>
  3. <?dbhtml filename="gcc.html" dir="chapter06"?>
  4. <para>The GCC package contains the GNU compiler collection, among them
  5. the C and C++ compilers.</para>
  6. <screen>&buildtime; &gcc-time;
  7. &diskspace; &gcc-compsize;</screen>
  8. <literallayout>Official download location for GCC (&gcc-version;):
  9. <ulink url="ftp://ftp.gnu.org/pub/gnu/gcc/"/>
  10. And for the GCC No-Fixincludes Patch:
  11. <ulink url="&patches-root;&gcc-nofixincludes-patch;"/></literallayout>
  12. &aa-gcc-dep;
  13. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  14. <sect2>
  15. <title>Installation of GCC</title>
  16. <note><para>The test suite for GCC in this section is considered
  17. <emphasis>critical</emphasis>. Our advice is to not skip it under any
  18. circumstance.</para></note>
  19. <para>This package is known to behave badly when you have changed its
  20. default optimization flags (including the -march and -mcpu options).
  21. Therefore, if you have defined any environment variables that override
  22. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  23. or modifying them when building GCC.</para>
  24. <para>Unpack the GCC-core <emphasis>and</emphasis> the GCC-g++ tarball -- they
  25. will unfold into the same directory. You should likewise extract the
  26. GCC-testsuite package. The full GCC package contains even more
  27. compilers. Instructions for building these can be found at
  28. <ulink url="&blfs-root;view/stable/general/gcc.html"/>.</para>
  29. <note><para>Be careful <emphasis role="strong">not</emphasis> to apply the GCC
  30. Specs patch from <xref linkend="chapter05"/> here.</para></note>
  31. <para>First apply the No-Fixincludes patch that we also used in the previous
  32. chapter:</para>
  33. <screen><userinput>patch -Np1 -i ../&gcc-nofixincludes-patch;</userinput></screen>
  34. <para>Now apply a sed substitution that will suppress the installation of
  35. <filename>libiberty.a</filename>. We want to use the version of
  36. <filename>libiberty.a</filename> provided by Binutils:</para>
  37. <screen><userinput>sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
  38. <para>The GCC documentation recommends building GCC outside of the source
  39. directory in a dedicated build directory:</para>
  40. <screen><userinput>mkdir ../gcc-build
  41. cd ../gcc-build</userinput></screen>
  42. <para>Now prepare GCC for compilation:</para>
  43. <screen><userinput>../&gcc-dir;/configure --prefix=/usr \
  44. &nbsp;&nbsp;&nbsp;&nbsp;--enable-shared --enable-threads=posix \
  45. &nbsp;&nbsp;&nbsp;&nbsp;--enable-__cxa_atexit --enable-clocale=gnu \
  46. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c,c++</userinput></screen>
  47. <para>Compile the package:</para>
  48. <screen><userinput>make</userinput></screen>
  49. <para>Test the results, but don't stop at errors (you'll remember the few
  50. known ones):</para>
  51. <screen><userinput>make -k check</userinput></screen>
  52. <para>The test suite notes from <xref linkend="ch-tools-gcc-pass2"/> are still very
  53. much appropriate here. Be sure to refer back there should you have any
  54. doubts.</para>
  55. <para>And install the package:</para>
  56. <screen><userinput>make install</userinput></screen>
  57. <para>Some packages expect the C PreProcessor to be installed in the
  58. <filename>/lib</filename> directory.
  59. To honor those packages, create this symlink:</para>
  60. <screen><userinput>ln -s ../usr/bin/cpp /lib</userinput></screen>
  61. <para>Many packages use the name <userinput>cc</userinput> to call the C
  62. compiler. To satisfy those packages, create a symlink:</para>
  63. <screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen>
  64. <note><para>At this point it is strongly recommended to repeat the sanity check
  65. we performed earlier in this chapter. Refer back to
  66. <xref linkend="ch-system-adjustingtoolchain"/> and repeat the check. If the results
  67. are wrong, then most likely you erroneously applied the GCC Specs patch from
  68. <xref linkend="chapter05"/>.</para></note>
  69. </sect2>
  70. &aa-gcc-shortdesc;
  71. &aa-gcc-desc;
  72. </sect1>