gcc-pass1-inst.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <sect2><title>&nbsp;</title><para>&nbsp;</para></sect2>
  2. <sect2>
  3. <title>Installation of GCC</title>
  4. <para>Unpack only the GCC-core tarball, as we won't be needing a C++ compiler
  5. for the moment.</para>
  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>It is recommended by the GCC installation documentation to build
  12. GCC outside of the source directory in a dedicated directory:</para>
  13. <para><screen><userinput>mkdir ../gcc-build
  14. cd ../gcc-build</userinput></screen></para>
  15. <para>Prepare GCC to be compiled:</para>
  16. <para><screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  17. &nbsp;&nbsp;&nbsp;&nbsp;--with-local-prefix=/tools \
  18. &nbsp;&nbsp;&nbsp;&nbsp;--disable-nls --enable-shared \
  19. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c</userinput></screen></para>
  20. <para>The meaning of the new configure options:</para>
  21. <itemizedlist>
  22. <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
  23. purpose of this switch is to remove <filename>/usr/local/include</filename>
  24. from <userinput>gcc</userinput>'s include search path. This is not absolutely
  25. essential, but we want to try and minimize the influence from the host system,
  26. so this seems a logical thing to do.</para></listitem>
  27. <listitem><para><userinput>--enable-shared</userinput>: This switch may
  28. seem counter-intuitive at first. But using it allows the building of
  29. <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
  30. having <filename>libgcc_eh.a</filename> available ensures that the configure
  31. script for Glibc (the next package we compile) produces the proper results.
  32. Note that the <userinput>gcc</userinput> binaries will still be linked
  33. statically, as this is controlled by the <userinput>-static</userinput>
  34. value of BOOT_LDFLAGS further on.</para></listitem>
  35. <listitem><para><userinput>--enable-languages=c</userinput>: This option
  36. ensures that only the C compiler is built. The option is only needed when you
  37. have downloaded and unpacked the full GCC tarball.</para></listitem>
  38. </itemizedlist>
  39. <para>Continue with compiling the package:</para>
  40. <para><screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen></para>
  41. <para>The meaning of the make parameters:</para>
  42. <itemizedlist>
  43. <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
  44. GCC to link its programs statically.</para></listitem>
  45. <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
  46. compile GCC, but compiles it several times. It uses the programs compiled in
  47. a first round to compile itself a second time, and then again a third time.
  48. It then compares these second and third compiles to make sure it can
  49. reproduce itself flawlessly, which most probably means that it was
  50. compiled correctly.</para></listitem>
  51. </itemizedlist>
  52. <para>And install the package:</para>
  53. <para><screen><userinput>make install</userinput></screen></para>
  54. <para>As a finishing touch we'll create the <filename
  55. class="symlink">/tools/bin/cc</filename> symlink. Many programs and
  56. scripts run <userinput>cc</userinput> instead of <userinput>gcc</userinput>,
  57. a thing meant to keep programs generic and therefore usable on all kinds of
  58. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  59. <userinput>cc</userinput> leaves the system administrator free to decide what
  60. C compiler to install, as long as there's a symlink pointing to it:</para>
  61. <para><screen><userinput>ln -sf gcc /tools/bin/cc</userinput></screen></para>
  62. </sect2>