binutils-pass1.xml 4.7 KB

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