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 have changed its default
  15. optimization flags (including the -march and -mcpu options). Therefore, if
  16. you have defined any environment variables that override default
  17. optimizations, such as CFLAGS and CXXFLAGS, we recommend unsetting or
  18. modifying 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. To
  25. achieve this easily, you could do something like:
  26. <userinput>time { ./configure ... &amp;&amp; ... &amp;&amp; ... &amp;&amp; make install; }</userinput>.</para></note>
  27. <para>Now prepare Binutils for compilation:</para>
  28. <screen><userinput>../&binutils-dir;/configure --prefix=/tools --disable-nls</userinput></screen>
  29. <para>The meaning of the configure options:</para>
  30. <itemizedlist>
  31. <listitem><para><userinput>--prefix=/tools</userinput>: This tells the
  32. configure script to prepare to install the Binutils programs in the
  33. <filename>/tools</filename> directory.</para></listitem>
  34. <listitem><para><userinput>--disable-nls</userinput>: This disables
  35. internationalization (a word often shortened to i18n). We don't need this
  36. for our static programs and <emphasis>nls</emphasis> often causes problems
  37. when linking statically.</para></listitem>
  38. </itemizedlist>
  39. <para>Continue with compiling the package:</para>
  40. <screen><userinput>make configure-host
  41. make LDFLAGS="-all-static"</userinput></screen>
  42. <para>The meaning of the make parameters:</para>
  43. <itemizedlist>
  44. <listitem><para><userinput>configure-host</userinput>: This forces all the
  45. subdirectories to be configured immediately. A statically linked build will
  46. fail without it. We therefore use this option to work around the
  47. problem.</para></listitem>
  48. <listitem><para><userinput>LDFLAGS="-all-static"</userinput>: This tells the
  49. linker that all the Binutils programs should be linked statically. However,
  50. strictly speaking, <emphasis>"-all-static"</emphasis> is first passed to the
  51. <command>libtool</command> program which then passes
  52. <emphasis>"-static"</emphasis> on to the linker.</para></listitem>
  53. </itemizedlist>
  54. <para>Compilation is now complete. This is the point where we would normally
  55. run the test suite. But as discussed earlier, we don't recommend running the
  56. test suites for the temporary tools here in this chapter. However, even if we
  57. still wanted to run the Binutils test suite, we're unable do so at this early
  58. stage because the test suite framework is not yet in place. Not only that, the
  59. programs from this first pass will soon be overwritten by those installed in
  60. the second pass.</para>
  61. <para>And install the package:</para>
  62. <screen><userinput>make install</userinput></screen>
  63. <para>Now prepare the linker for the "locking in" of Glibc 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, but only in the <filename>ld</filename>
  70. subdirectory.</para></listitem>
  71. <listitem><para><userinput>-C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib</userinput>:
  72. This option rebuilds everything in the <filename>ld</filename> subdirectory.
  73. Specifying the LIB_PATH makefile variable on the command line allows us to
  74. override the default value and have it point to our temporary tools location.
  75. The value of this variable specifies the linker's default library search path.
  76. You'll see how this preparation is used later on in the
  77. chapter.</para></listitem>
  78. </itemizedlist>
  79. <!-- HACK - Force some whitespace to appease tidy -->
  80. <literallayout></literallayout>
  81. <warning><para>Do not yet remove the Binutils build and source directories. You
  82. will need them again in their current state a bit further on in this
  83. 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>