gcc-pass1.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-tools-gcc-pass1">
  7. <title>GCC-&gcc-version; - Pass 1</title>
  8. <?dbhtml filename="gcc-pass1.html"?>
  9. <indexterm zone="ch-tools-gcc-pass1">
  10. <primary sortas="a-GCC">GCC</primary>
  11. <secondary>tools, pass 1</secondary></indexterm>
  12. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/para[1])"/>
  13. <screen>&buildtime; 4.4 SBU
  14. &diskspace; 300 MB</screen>
  15. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/gcc.xml" xpointer="xpointer(/sect1/para[2])"/>
  16. <sect2>
  17. <title>Installation of GCC</title>
  18. <para>Unpack only the GCC-core tarball, as we won't be needing the C++ compiler
  19. nor the test suite here.</para>
  20. <para>This package is known to behave badly when you change its default
  21. optimization flags (including the <emphasis>-march</emphasis> and
  22. <emphasis>-mcpu</emphasis> options). Therefore, if you have defined any
  23. environment variables that override default optimizations, such as CFLAGS and
  24. CXXFLAGS, we recommend un-setting them when building GCC.</para>
  25. <para>The GCC documentation recommends building GCC outside of the source
  26. directory in a dedicated build directory:</para>
  27. <screen><userinput>mkdir ../gcc-build
  28. cd ../gcc-build</userinput></screen>
  29. <para>Prepare GCC for compilation:</para>
  30. <screen><userinput>../gcc-&gcc-version;/configure --prefix=/tools \
  31. --libexecdir=/tools/lib --with-local-prefix=/tools \
  32. --disable-nls --enable-shared --enable-languages=c</userinput></screen>
  33. <para>The meaning of the configure options:</para>
  34. <itemizedlist>
  35. <listitem><para><userinput>--with-local-prefix=/tools</userinput>: The
  36. purpose of this switch is to remove <filename>/usr/local/include</filename>
  37. from <command>gcc</command>'s include search path. This is not absolutely
  38. essential; however, we want to try to minimize the influence of the host
  39. system, so this a sensible thing to do.</para></listitem>
  40. <listitem><para><userinput>--enable-shared</userinput>: This switch may
  41. seem counter-intuitive at first. But using it allows the building of
  42. <filename>libgcc_s.so.1</filename> and <filename>libgcc_eh.a</filename>, and
  43. having <filename>libgcc_eh.a</filename> available ensures that the configure
  44. script for Glibc (the next package we compile) produces the proper results.
  45. Note that the <command>gcc</command> binaries will still be linked
  46. statically, as this is controlled by the <emphasis>-static</emphasis>
  47. value of BOOT_LDFLAGS in the next step.</para></listitem>
  48. <listitem><para><userinput>--enable-languages=c</userinput>: This option
  49. ensures that only the C compiler is built. The option is only needed when you
  50. have downloaded and unpacked the full GCC tarball.</para></listitem>
  51. </itemizedlist>
  52. <para>Continue with compiling the package:</para>
  53. <screen><userinput>make BOOT_LDFLAGS="-static" bootstrap</userinput></screen>
  54. <para>The meaning of the make parameters:</para>
  55. <itemizedlist>
  56. <listitem><para><userinput>BOOT_LDFLAGS="-static"</userinput>: This tells
  57. GCC to link its programs statically.</para></listitem>
  58. <listitem><para><userinput>bootstrap</userinput>: This target doesn't just
  59. compile GCC, but compiles it several times. It uses the programs compiled in
  60. a first round to compile itself a second time, and then again a third time.
  61. It then compares these second and third compiles to make sure it can
  62. reproduce itself flawlessly, which most probably means that it was
  63. compiled correctly.</para></listitem>
  64. </itemizedlist>
  65. <para>Compilation is now complete, and at this point we would normally run the
  66. test suite. But, as mentioned before, the test suite framework is not in place
  67. yet. And there would be little point in running the tests anyhow, since the
  68. programs from this first pass will soon be replaced.</para>
  69. <para>Now install the package:</para>
  70. <screen><userinput>make install</userinput></screen>
  71. <para>As a finishing touch we'll create a symlink. Many programs and scripts
  72. run <command>cc</command> instead of <command>gcc</command>,
  73. a thing meant to keep programs generic and therefore usable on all kinds of
  74. Unix systems. Not everybody has the GNU C compiler installed. Simply running
  75. <command>cc</command> leaves the system administrator free to decide what
  76. C compiler to install, as long as there's a symlink pointing to it:</para>
  77. <screen><userinput>ln -s gcc /tools/bin/cc</userinput></screen>
  78. </sect2>
  79. <sect2><title/>
  80. <para>The details on this package are found in <xref linkend="contents-gcc"/>.</para>
  81. </sect2>
  82. </sect1>