binutils-pass1.xml 5.0 KB

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