gcc.xml 3.5 KB

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