gcc-pass1-inst.xml 3.8 KB

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