gcc.xml 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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>This time we will build both the C and the C++ compiler, so you'll have
  20. to unpack the GCC-core <emphasis>and</emphasis> the GCC-g++ tarball -- they
  21. will unfold into the same directory. You should likewise extract the
  22. GCC-testsuite package. The full GCC package contains even more
  23. compilers. Instructions for building these can be found at
  24. <ulink url="&blfs-root;view/stable/general/gcc.html"/>.</para>
  25. <screen><userinput>patch -Np1 -i ../&gcc-nofixincludes-patch;
  26. patch -Np1 -i ../&gcc-suppress-libiberty-patch;</userinput></screen>
  27. <para>The second patch here suppresses the installation of libiberty from GCC,
  28. as we will use the one provided by binutils instead. Be careful
  29. <emphasis>not</emphasis> to apply the GCC specs patch from Chapter 5
  30. here.</para>
  31. <para>The GCC documentation recommends building GCC outside of the source
  32. directory in a dedicated build directory:</para>
  33. <screen><userinput>mkdir ../gcc-build
  34. cd ../gcc-build</userinput></screen>
  35. <para>Now prepare GCC for compilation:</para>
  36. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr \
  37. &nbsp;&nbsp;&nbsp;&nbsp;--enable-shared --enable-threads=posix \
  38. &nbsp;&nbsp;&nbsp;&nbsp;--enable-__cxa_atexit --enable-clocale=gnu \
  39. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c,c++</userinput></screen>
  40. <para>Compile the package:</para>
  41. <screen><userinput>make</userinput></screen>
  42. <para>Test the results, but don't stop at errors (you'll remember the few
  43. known ones):</para>
  44. <screen><userinput>make -k check</userinput></screen>
  45. <para>The test suite notes from <xref linkend="ch05-gcc-pass2"/> are still very
  46. much appropriate here. Be sure to refer back there should you have any
  47. doubts.</para>
  48. <para>And install the package:</para>
  49. <screen><userinput>make install</userinput></screen>
  50. <para>Some packages expect the C PreProcessor to be installed in the
  51. <filename>/lib</filename> directory.
  52. To honor those packages, create this symlink:</para>
  53. <screen><userinput>ln -s ../usr/bin/cpp /lib</userinput></screen>
  54. <para>Many packages use the name <userinput>cc</userinput> to call the C
  55. compiler. To satisfy those packages, create a symlink:</para>
  56. <screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen>
  57. <note><para>At this point it is strongly recommended to repeat the sanity check
  58. we performed earlier in this chapter. Refer back to
  59. <xref linkend="ch06-adjustingtoolchain"/> and repeat the check. If the results
  60. are wrong, then most likely you erroneously applied the GCC Specs patch from
  61. Chapter 5.</para></note>
  62. </sect2>
  63. </sect1>