gcc-pass1-inst.xml 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. <note><para>Even though GCC is an important toolchain package, we are not
  7. going to run the test suite at this early stage. First, the test suite framework
  8. is not yet in place and second, the programs from this first pass will soon be
  9. overwritten by those installed in the second pass.</para></note>
  10. <para>This package is known to behave badly when you have changed its
  11. default optimization flags (including the -march and -mcpu options).
  12. Therefore, if you have defined any environment variables that override
  13. default optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting
  14. or modifying them when building GCC.</para>
  15. <para>The GCC documentation recommends building GCC outside of the source
  16. directory in a dedicated build directory:</para>
  17. <screen><userinput>mkdir ../gcc-build
  18. cd ../gcc-build</userinput></screen>
  19. <para>Prepare GCC to be compiled:</para>
  20. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  21. &nbsp;&nbsp;&nbsp;&nbsp;--with-local-prefix=/tools \
  22. &nbsp;&nbsp;&nbsp;&nbsp;--disable-nls --enable-shared \
  23. &nbsp;&nbsp;&nbsp;&nbsp;--enable-languages=c</userinput></screen>
  24. <para>The meaning of the configure options:</para>
  25. <itemizedlist>
  26. <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
  27. purpose of this switch is to remove <filename>/usr/local/include</filename>
  28. from <userinput>gcc</userinput>'s include search path. This is not absolutely
  29. essential; however, we want to try to minimize the influence of the host
  30. system, thus making this a sensible thing to do.</para></listitem>
  31. <listitem><para><userinput>--enable-shared</userinput>: This switch may
  32. seem counter-intuitive at first. But using it allows the building of
  33. <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
  34. having <filename>libgcc_eh.a</filename> available ensures that the configure
  35. script for Glibc (the next package we compile) produces the proper results.
  36. Note that the <userinput>gcc</userinput> binaries will still be linked
  37. statically, as this is controlled by the <userinput>-static</userinput>
  38. value of BOOT_LDFLAGS further on.</para></listitem>
  39. <listitem><para><userinput>--enable-languages=c</userinput>: This option
  40. ensures that only the C compiler is built. The option is only needed when you
  41. have downloaded and unpacked the full GCC tarball.</para></listitem>
  42. </itemizedlist>
  43. <para>Continue with compiling the package:</para>
  44. <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
  45. <para>The meaning of the make parameters:</para>
  46. <itemizedlist>
  47. <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
  48. GCC to link its programs statically.</para></listitem>
  49. <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
  50. compile GCC, but compiles it several times. It uses the programs compiled in
  51. a first round to compile itself a second time, and then again a third time.
  52. It then compares these second and third compiles to make sure it can
  53. reproduce itself flawlessly, which most probably means that it was
  54. compiled correctly.</para></listitem>
  55. </itemizedlist>
  56. <para>And install the package:</para>
  57. <screen><userinput>make install</userinput></screen>
  58. <para>As a finishing touch we'll create the <filename
  59. class="symlink">/tools/bin/cc</filename> symlink. Many programs and
  60. scripts run <userinput>cc</userinput> instead of <userinput>gcc</userinput>,
  61. a thing meant to keep programs generic and therefore usable on all kinds of
  62. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  63. <userinput>cc</userinput> leaves the system administrator free to decide what
  64. C compiler to install, as long as there's a symlink pointing to it:</para>
  65. <screen><userinput>ln -sf gcc /tools/bin/cc</userinput></screen>
  66. </sect2>