binutils-pass1.xml 4.7 KB

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