gcc-inst.xml 3.0 KB

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