gcc-inst.xml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Installation of GCC</title>
  4. <para>This package is known to behave badly when you have changed its
  5. default optimization flags (including the -march and -mcpu options). GCC is
  6. best left alone. Therefore, if you have defined any environment variables
  7. that override default optimizations, such as CFLAGS and CXXFLAGS, we
  8. recommend unsetting or modifying them when building GCC. You have
  9. been warned.</para>
  10. <para>We will be building the C and C++ compilers at this time, so you'll
  11. need to unpack both the gcc-core and gcc-g++ tarballs. Other compilers are
  12. available in the full gcc package; instructions for building them may be
  13. found at <ulink url="&blfs-root;view/cvs/general/gcc.html"/>.</para>
  14. <para>It is recommended by the GCC installation documentation to build GCC
  15. in a dedicated directory outside of the source tree. Create the build
  16. directory:</para>
  17. <para><screen><userinput>mkdir ../gcc-build &amp;&amp;
  18. cd ../gcc-build</userinput></screen></para>
  19. <para>Prepare GCC to be compiled:</para>
  20. <para><screen><userinput>../gcc-&gcc-version;/configure --prefix=/usr --enable-shared \
  21. &nbsp;&nbsp;&nbsp;&nbsp;--enable-threads=posix --with-slibdir=/lib \
  22. &nbsp;&nbsp;&nbsp;&nbsp;--enable-__cxa_atexit --enable-clocale=gnu</userinput></screen></para>
  23. <para>The meanings of the configure options are:</para>
  24. <itemizedlist>
  25. <listitem><para><userinput>--enable-threads=posix:</userinput> This enables
  26. C++ exception handling for multi-threaded code.</para></listitem>
  27. <listitem><para><userinput>--enable-__cxa_atexit:</userinput> This option
  28. will result in C++ shared libraries and C++ programs that are interoperable
  29. with other Linux distributions.</para></listitem>
  30. <listitem><para><userinput>--enable-clocale=gnu:</userinput> There is a risk
  31. that some people will build ABI incompatible C++ libraries if they didn't
  32. install all of the glibc localedata. Using --enable-clocale=gnu ensures that
  33. the "right thing" is done in all cases. If you don't wish to use this option,
  34. then at least build the <emphasis>de_DE</emphasis> locale. When GCC finds
  35. this specific locale, then the correct locale mode (<emphasis>gnu</emphasis>)
  36. is implemented.</para></listitem>
  37. </itemizedlist>
  38. <para>Continue with compiling the package:</para>
  39. <para><screen><userinput>make bootstrap</userinput></screen></para>
  40. <para>The <emphasis>bootstrap</emphasis> target doesn't just compile GCC, but
  41. it compiles GCC a multiple times. It uses the first compiled programs to
  42. compile itself a second and third time to make sure the compiler was compiled
  43. properly.</para>
  44. <para>Finish installing the package:</para>
  45. <para><screen><userinput>make install</userinput></screen></para>
  46. <para>Some packages require that the C++ compiler be installed in the
  47. <filename>/lib</filename> and <filename>/usr/lib</filename> directories.
  48. To honor those packages, create two symlinks:</para>
  49. <para><screen><userinput>ln -s ../usr/bin/cpp /lib &amp;&amp;
  50. ln -s ../bin/cpp /usr/lib</userinput></screen></para>
  51. <para>Many packages compile using <emphasis>cc</emphasis> as the name for
  52. the C compiler. To satisfy those packages, create a <emphasis>cc</emphasis>
  53. symlink:</para>
  54. <para><screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen></para>
  55. </sect2>