gcc-inst.xml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Installation of GCC</title>
  4. <note><para>The testsuite for GCC in this chapter is considered <emphasis>
  5. critical</emphasis>. Do not skip it under any circumstances.</para></note>
  6. <para>This package is known to behave badly when you have changed its
  7. default optimization flags (including the -march and -mcpu options).
  8. Therefore, if you have defined any environment variables that override
  9. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  10. or modifying them when building GCC.</para>
  11. <para>This time we will build both the C and the C++ compiler, so you'll have
  12. to unpack the GCC-core <emphasis>and</emphasis> the GCC-g++ tarball -- they
  13. will unfold into the same directory. You should likewise extract the
  14. GCC-testsuite package. The full GCC package contains even more
  15. compilers. Instructions for building these can be found at
  16. <ulink url="&blfs-root;view/cvs/general/gcc.html"/>.</para>
  17. <para><screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-2.patch
  18. patch -Np1 -i ../gcc-3.3.1-suppress-libiberty.patch</userinput></screen></para>
  19. <para>The second patch here suppresses the installation of libiberty from GCC,
  20. as we will use the one provided by binutils instead.</para>
  21. <para>GCC's installation documentation recommends to build the package in a
  22. dedicated directory separate from the source tree. Create this build
  23. directory and go there:</para>
  24. <para><screen><userinput>mkdir ../gcc-build
  25. cd ../gcc-build</userinput></screen></para>
  26. <para>Now prepare GCC for compilation:</para>
  27. <para><screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr \
  28. &nbsp;&nbsp;&nbsp;&nbsp;--enable-shared --enable-threads=posix \
  29. &nbsp;&nbsp;&nbsp;&nbsp;--enable-__cxa_atexit --enable-clocale=gnu \
  30. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c,c++</userinput></screen></para>
  31. <para>The meaning of the new configure options:</para>
  32. <itemizedlist>
  33. <listitem><para><userinput>--enable-threads=posix</userinput>: This enables
  34. C++ exception handling for multi-threaded code.</para></listitem>
  35. <listitem><para><userinput>--enable-__cxa_atexit</userinput>: This option
  36. will result in C++ shared libraries and C++ programs that are interoperable
  37. with other Linux distributions.</para></listitem>
  38. <listitem><para><userinput>--enable-clocale=gnu</userinput>: There is a risk
  39. that some people will build ABI incompatible C++ libraries if they didn't
  40. install all of the glibc localedata. Using --enable-clocale=gnu ensures that
  41. the "right thing" is done in all cases. If you don't wish to use this option,
  42. then at least build the <emphasis>de_DE</emphasis> locale. When GCC finds
  43. this specific locale, then the correct locale mode (<emphasis>gnu</emphasis>)
  44. is implemented.</para></listitem>
  45. </itemizedlist>
  46. <para>Compile the package:</para>
  47. <para><screen><userinput>make</userinput></screen></para>
  48. <para>Test the results, but don't stop at errors (you'll remember the few
  49. known ones):</para>
  50. <para><screen><userinput>make -k check</userinput></screen></para>
  51. <para>And install the package:</para>
  52. <para><screen><userinput>make install</userinput></screen></para>
  53. <para>Some packages expect the C PreProcessor to be installed in the
  54. <filename>/lib</filename> directory.
  55. To honor those packages, create this symlink:</para>
  56. <para><screen><userinput>ln -s ../usr/bin/cpp /lib</userinput></screen></para>
  57. <para>Many packages use the name <userinput>cc</userinput> to call the C
  58. compiler. To satisfy those packages, create a symlink:</para>
  59. <para><screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen></para>
  60. </sect2>