binutils-pass1.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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-binutils-pass1">
  7. <title>Binutils-&binutils-version; - Pass 1</title>
  8. <?dbhtml filename="binutils-pass1.html"?>
  9. <indexterm zone="ch-tools-binutils-pass1">
  10. <primary sortas="a-Binutils">Binutils</primary>
  11. <secondary>tools, pass 1</secondary></indexterm>
  12. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/para[1])"/>
  13. <screen>&buildtime; 1.0 SBU
  14. &diskspace; 194 MB</screen>
  15. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/para[2])"/>
  16. <sect2>
  17. <title>Installation of Binutils</title>
  18. <para>It is important that Binutils be the first package to get compiled,
  19. because both Glibc and GCC perform various tests on the available linker and
  20. assembler to determine which of their own features to enable.</para>
  21. <para>This package is known to behave badly when you change its default
  22. optimization flags (including the <emphasis>-march</emphasis> and
  23. <emphasis>-mcpu</emphasis> options). Therefore, if you have defined any
  24. environment variables that override default optimizations, such as CFLAGS and
  25. CXXFLAGS, we recommend un-setting them when building Binutils.</para>
  26. <para>The Binutils documentation recommends building Binutils outside of the
  27. source directory in a dedicated build directory:</para>
  28. <screen><userinput>mkdir ../binutils-build
  29. cd ../binutils-build</userinput></screen>
  30. <note><para>If you want the SBU values listed in the rest of the book to be of
  31. any use, you will have to measure the time it takes to build this package --
  32. from the configuration up to and including the first install. To achieve this
  33. easily, you could wrap the four commands in a <command>time</command> command
  34. like this: <userinput>time { ./configure ... &amp;&amp; ... &amp;&amp; ...
  35. &amp;&amp; make install; }</userinput>.</para></note>
  36. <para>Now prepare Binutils for compilation:</para>
  37. <screen><userinput>../binutils-&binutils-version;/configure --prefix=/tools --disable-nls</userinput></screen>
  38. <para>The meaning of the configure options:</para>
  39. <itemizedlist>
  40. <listitem><para><userinput>--prefix=/tools</userinput>: This tells the
  41. configure script to prepare to install the Binutils programs in the
  42. <filename>/tools</filename> directory.</para></listitem>
  43. <listitem><para><userinput>--disable-nls</userinput>: This disables
  44. internationalization (a word often shortened to i18n). We don't need this
  45. for our static programs and <emphasis>nls</emphasis> often causes problems
  46. when linking statically.</para></listitem>
  47. </itemizedlist>
  48. <para>Continue with compiling the package:</para>
  49. <screen><userinput>make configure-host
  50. make LDFLAGS="-all-static"</userinput></screen>
  51. <para>The meaning of the make parameters:</para>
  52. <itemizedlist>
  53. <listitem><para><userinput>configure-host</userinput>: This forces all the
  54. subdirectories to be configured immediately. A statically linked build will
  55. fail without it. We therefore use this option to work around the
  56. problem.</para></listitem>
  57. <listitem><para><userinput>LDFLAGS="-all-static"</userinput>: This tells the
  58. linker that all the Binutils programs should be linked statically. However,
  59. strictly speaking, <emphasis>"-all-static"</emphasis> is passed to the
  60. <command>libtool</command> program, which then passes
  61. <emphasis>"-static"</emphasis> to the linker.</para></listitem>
  62. </itemizedlist>
  63. <para>Compilation is complete. Normally we would now run the test suite, but
  64. at this early stage the test suite framework (Tcl, Expect and DejaGnu) is not
  65. yet in place. And there would be little point in running the tests anyhow,
  66. since the programs from this first pass will soon be replaced by those from the
  67. second.</para>
  68. <para>Now install the package:</para>
  69. <screen><userinput>make install</userinput></screen>
  70. <para>Now prepare the linker for the <quote>Adjusting</quote> phase later on:</para>
  71. <screen><userinput>make -C ld clean
  72. make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib</userinput></screen>
  73. <para>The meaning of the make parameters:</para>
  74. <itemizedlist>
  75. <listitem><para><userinput>-C ld clean</userinput>: This tells the make program
  76. to remove all the compiled files in the <filename class="directory">ld</filename> subdirectory.</para></listitem>
  77. <listitem><para><userinput>-C ld LDFLAGS="-all-static"
  78. LIB_PATH=/tools/lib</userinput>: This option rebuilds everything in the
  79. <filename class="directory">ld</filename> subdirectory. Specifying the LIB_PATH
  80. makefile variable on the command line allows us to override the default value
  81. and have it point to our temporary tools location. The value of this variable
  82. specifies the linker's default library search path. You will see how this
  83. preparation is used later on in the chapter.</para></listitem>
  84. </itemizedlist>
  85. <warning><para><emphasis>Do not yet remove</emphasis> the Binutils build and
  86. source directories. You will need them again in their current state a bit
  87. further on in this chapter.</para></warning>
  88. </sect2>
  89. <sect2><title> </title><para> </para>
  90. <para>The details on this package are found in <xref linkend="contents-binutils"/>.</para>
  91. <para> </para></sect2>
  92. </sect1>