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. <para>This package is known to behave badly when you have changed its
  17. default optimization flags (including the -march and -mcpu options).
  18. Therefore, if you have defined any environment variables that override
  19. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  20. or modifying them when building GCC.</para>
  21. <para>Unpack the GCC-core <emphasis>and</emphasis> the GCC-g++ tarball -- they
  22. will unfold into the same directory. You should likewise extract the
  23. GCC-testsuite package. The full GCC package contains even more
  24. compilers. Instructions for building these can be found at
  25. <ulink url="&blfs-root;view/stable/general/gcc.html"/>.</para>
  26. <note><para>Be careful <emphasis role="strong">not</emphasis> to apply the GCC
  27. Specs patch from <xref linkend="chapter05"/> here.</para></note>
  28. <para>First apply the No-Fixincludes patch that we also used in the previous
  29. chapter:</para>
  30. <screen><userinput>patch -Np1 -i ../&gcc-nofixincludes-patch;</userinput></screen>
  31. <para>Now apply a sed substitution that will suppress the installation of
  32. <filename>libiberty.a</filename>. We want to use the version of
  33. <filename>libiberty.a</filename> provided by Binutils:</para>
  34. <screen><userinput>sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in</userinput></screen>
  35. <para>The GCC documentation recommends building GCC outside of the source
  36. directory in a dedicated build directory:</para>
  37. <screen><userinput>mkdir ../gcc-build
  38. cd ../gcc-build</userinput></screen>
  39. <para>Now prepare GCC for compilation:</para>
  40. <screen><userinput>../&gcc-dir;/configure --prefix=/usr \
  41. &nbsp;&nbsp;&nbsp;&nbsp;--enable-shared --enable-threads=posix \
  42. &nbsp;&nbsp;&nbsp;&nbsp;--enable-__cxa_atexit --enable-clocale=gnu \
  43. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c,c++</userinput></screen>
  44. <para>Compile the package:</para>
  45. <screen><userinput>make</userinput></screen>
  46. <important><para>The test suite for GCC in this section is considered
  47. <emphasis>critical</emphasis>. Our advice is to not skip it under any
  48. circumstance.</para></important>
  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 <command>cc</command> 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>