gcc-inst.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Installation of GCC</title>
  4. <note><para>The test suite for GCC in this section is considered <emphasis>
  5. critical</emphasis>. Our advice is to not skip it under any
  6. circumstances.</para></note>
  7. <para>This package is known to behave badly when you have changed its
  8. default optimization flags (including the -march and -mcpu options).
  9. Therefore, if you have defined any environment variables that override
  10. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  11. or modifying them when building GCC.</para>
  12. <para>This time we will build both the C and the C++ compiler, so you'll have
  13. to unpack the GCC-core <emphasis>and</emphasis> the GCC-g++ tarball -- they
  14. will unfold into the same directory. You should likewise extract the
  15. GCC-testsuite package. The full GCC package contains even more
  16. compilers. Instructions for building these can be found at
  17. <ulink url="&blfs-root;view/cvs/general/gcc.html"/>.</para>
  18. <para><screen><userinput>patch -Np1 -i ../gcc-&gcc-version;-no_fixincludes-2.patch
  19. patch -Np1 -i ../gcc-3.3.1-suppress-libiberty.patch</userinput></screen></para>
  20. <para>The second patch here suppresses the installation of libiberty from GCC,
  21. as we will use the one provided by binutils instead.</para>
  22. <para>The GCC documentation recommends building GCC outside of the source
  23. directory in a dedicated build directory:</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>Compile the package:</para>
  32. <para><screen><userinput>make</userinput></screen></para>
  33. <note><para>At this point it is strongly recommended to repeat the sanity check
  34. we performed earlier in the chapter. Refer back to the "Re-adjusting the
  35. toolchain" section and repeat the check. If the results are wrong then most
  36. likely, you erroneously applied the GCC Specs patch from Chapter 5.</para></note>
  37. <para>Test the results, but don't stop at errors (you'll remember the few
  38. known ones):</para>
  39. <para><screen><userinput>make -k check</userinput></screen></para>
  40. <para>And install the package:</para>
  41. <para><screen><userinput>make install</userinput></screen></para>
  42. <para>Some packages expect the C PreProcessor to be installed in the
  43. <filename>/lib</filename> directory.
  44. To honor those packages, create this symlink:</para>
  45. <para><screen><userinput>ln -s ../usr/bin/cpp /lib</userinput></screen></para>
  46. <para>Many packages use the name <userinput>cc</userinput> to call the C
  47. compiler. To satisfy those packages, create a symlink:</para>
  48. <para><screen><userinput>ln -s gcc /usr/bin/cc</userinput></screen></para>
  49. </sect2>