binutils-pass1.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
  3. <!ENTITY % general-entities SYSTEM "../general.ent">
  4. %general-entities;
  5. ]>
  6. <sect1 id="ch-tools-binutils-pass1" role="wrap">
  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. <sect2 role="package"><title/>
  13. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  14. <segmentedlist>
  15. <segtitle>&buildtime;</segtitle>
  16. <segtitle>&diskspace;</segtitle>
  17. <seglistitem><seg>1.0 SBU</seg><seg>194 MB</seg></seglistitem>
  18. </segmentedlist>
  19. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude" href="../chapter06/binutils.xml" xpointer="xpointer(/sect1/sect2[1]/segmentedlist[2])"/>
  20. </sect2>
  21. <sect2 role="installation">
  22. <title>Installation of Binutils</title>
  23. <para>It is important that Binutils be the first package compiled
  24. because both Glibc and GCC perform various tests on the available
  25. linker and assembler to determine which of their own features to
  26. enable.</para>
  27. <para>This package is known to have issues when its default
  28. optimization flags (including the <parameter>-march</parameter> and
  29. <parameter>-mcpu</parameter> options) are changed. If any environment
  30. variables that override default optimizations have been defined, such
  31. as <envar>CFLAGS</envar> and <envar>CXXFLAGS</envar>,
  32. unset them when building Binutils.</para>
  33. <para>The Binutils documentation recommends building Binutils outside of the
  34. source directory in a dedicated build directory:</para>
  35. <screen><userinput>mkdir ../binutils-build
  36. cd ../binutils-build</userinput></screen>
  37. <note><para>In order for the SBU values listed in the rest of the book
  38. to be of any use, measure the time it takes to build this package from
  39. the configuration, up to and including the first install. To achieve
  40. this easily, wrap the four commands in a <command>time</command>
  41. command like this: <userinput>time { ./configure ... &amp;&amp; ...
  42. &amp;&amp; ... &amp;&amp; make install; }</userinput>.</para></note>
  43. <para>Now prepare Binutils for compilation:</para>
  44. <screen><userinput>../binutils-&binutils-version;/configure --prefix=/tools \
  45. --disable-nls</userinput></screen>
  46. <para>The meaning of the configure options:</para>
  47. <variablelist>
  48. <varlistentry>
  49. <term><parameter>--prefix=/tools</parameter></term>
  50. <listitem><para>This tells the configure script to prepare to install the Binutils
  51. programs in the <filename class="directory">/tools</filename> directory.</para></listitem>
  52. </varlistentry>
  53. <varlistentry>
  54. <term><parameter>--disable-nls</parameter></term>
  55. <listitem><para>This disables internationalization. This is not needed
  56. for the static programs, and NLS can cause problems when linking
  57. statically.</para></listitem>
  58. </varlistentry>
  59. </variablelist>
  60. <para>Continue with compiling the package:</para>
  61. <screen><userinput>make configure-host
  62. make LDFLAGS="-all-static"</userinput></screen>
  63. <para>The meaning of the make parameters:</para>
  64. <variablelist>
  65. <varlistentry>
  66. <term><parameter>configure-host</parameter></term>
  67. <listitem><para>This forces all subdirectories to be configured
  68. immediately. A statically-linked build will fail without it. Use this
  69. option to work around the problem.</para></listitem>
  70. </varlistentry>
  71. <varlistentry>
  72. <term><parameter>LDFLAGS="-all-static"</parameter></term>
  73. <listitem><para>This tells the linker that all Binutils programs
  74. should be linked statically. However, strictly speaking,
  75. <parameter>"-all-static"</parameter> is passed to the
  76. <command>libtool</command> program, which then passes
  77. <parameter>"-static"</parameter> to the linker.</para></listitem>
  78. </varlistentry>
  79. </variablelist>
  80. <para>Compilation is now complete. Ordinarily we would now run the
  81. test suite, but at this early stage the test suite framework (Tcl,
  82. Expect, and DejaGNU) is not yet in place. The benefits of running the
  83. tests at this point are minimal since the programs from this
  84. first pass will soon be replaced by those from the second.</para>
  85. <para>Install the package:</para>
  86. <screen><userinput>make install</userinput></screen>
  87. <para>Next, prepare the linker for the <quote>Adjusting</quote> phase
  88. later on:</para>
  89. <screen><userinput>make -C ld clean
  90. make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib</userinput></screen>
  91. <para>The meaning of the make parameters:</para>
  92. <variablelist>
  93. <varlistentry>
  94. <term><parameter>-C ld clean</parameter></term>
  95. <listitem><para>This tells the make program to remove all compiled
  96. files in the <filename class="directory">ld</filename>
  97. subdirectory.</para></listitem>
  98. </varlistentry>
  99. <varlistentry>
  100. <term><parameter>-C ld LDFLAGS="-all-static"
  101. LIB_PATH=/tools/lib</parameter></term>
  102. <listitem><para>This option rebuilds everything in the
  103. <filename class="directory">ld</filename> subdirectory. Specifying
  104. the <envar>LIB_PATH</envar> Makefile variable on the command
  105. line allows us to override the default value
  106. and point it to the temporary tools location. The value of this variable
  107. specifies the linker's default library search path. This preparation
  108. is used later in the chapter.</para></listitem>
  109. </varlistentry>
  110. </variablelist>
  111. <warning><para><emphasis>Do not</emphasis> remove the Binutils
  112. build and source directories yet. These will be needed again in their
  113. current state later in this chapter.</para></warning>
  114. </sect2>
  115. <sect2 role="content"><title/>
  116. <para>Details on this package are located in <xref
  117. linkend="contents-binutils" role="."/></para>
  118. </sect2>
  119. </sect1>