binutils-pass1.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  4. <!ENTITY % general-entities SYSTEM "../general.ent">
  5. %general-entities;
  6. ]>
  7. <sect1 id="ch-tools-binutils-pass1" role="wrap">
  8. <?dbhtml filename="binutils-pass1.html"?>
  9. <title>Binutils-&binutils-version; - Pass 1</title>
  10. <indexterm zone="ch-tools-binutils-pass1">
  11. <primary sortas="a-Binutils">Binutils</primary>
  12. <secondary>tools, pass 1</secondary>
  13. </indexterm>
  14. <sect2 role="package">
  15. <title/>
  16. <xi:include xmlns:xi="http://www.w3.org/2003/XInclude"
  17. href="../chapter06/binutils.xml"
  18. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  19. <segmentedlist>
  20. <segtitle>&buildtime;</segtitle>
  21. <segtitle>&diskspace;</segtitle>
  22. <seglistitem>
  23. <seg>&binutils-ch5p1-sbu;</seg>
  24. <seg>&binutils-ch5p1-du;</seg>
  25. </seglistitem>
  26. </segmentedlist>
  27. </sect2>
  28. <sect2 role="installation">
  29. <title>Installation of Binutils</title>
  30. <para>It is important that Binutils be the first package compiled
  31. because both Glibc and GCC perform various tests on the available
  32. linker and assembler to determine which of their own features to
  33. enable.</para>
  34. <para>The Binutils documentation recommends building Binutils outside of the
  35. source directory in a dedicated build directory:</para>
  36. <screen><userinput>mkdir -v ../binutils-build
  37. cd ../binutils-build</userinput></screen>
  38. <note>
  39. <para>In order for the SBU values listed in the rest of the book
  40. to be of any use, measure the time it takes to build this package from
  41. the configuration, up to and including the first install. To achieve
  42. this easily, wrap the three commands in a <command>time</command>
  43. command like this: <userinput>time { ./configure ... &amp;&amp; make
  44. &amp;&amp; make install; }</userinput>.</para>
  45. </note>
  46. <para>Test to see if the host is a 64-bit capable machine and set a variable
  47. if it is.</para>
  48. <screen><userinput>test $(uname -m | grep 64) &amp;&amp; M64="-m64"</userinput></screen>
  49. <para>Now prepare Binutils for compilation:</para>
  50. <screen><userinput>CC="gcc -B/usr/bin/ $M64" ../binutils-&binutils-version;/configure \
  51. --prefix=/tools --disable-nls --disable-werror
  52. unset M64</userinput></screen>
  53. <variablelist>
  54. <title>The meaning of the configure options:</title>
  55. <varlistentry>
  56. <term><envar>CC="gcc -B/usr/bin/ $M64"</envar></term>
  57. <listitem>
  58. <para>This forces <command>gcc</command> to prefer the linker from
  59. the host in <filename class="directory">/usr/bin</filename>. This
  60. is necessary on some hosts where the new <command>ld</command>
  61. built here is not compatible with the host's <command>gcc</command>.
  62. </para>
  63. <para>Also, if the cpu-type is 64-bit capable, the variable <envar>$M64</envar>
  64. will contain the parameter <parameter>-m64</parameter>. Otherwise, the
  65. variable is empty. The parameter forces <command>gcc</command> to build
  66. 64-bit binaries. Using that parameter here and for the next package
  67. ensures creation of a linker, assembler and compiler that will in turn
  68. create only 64-bit binaries. This is necessary since currently this book
  69. does not support the creation of multilib systems, i.e., those with both
  70. 32-bit and 64-bit libraries. This will only make a difference on hosts that
  71. are themselves multilib and employ a compiler that creates 32-bit binaries
  72. by default.</para>
  73. </listitem>
  74. </varlistentry>
  75. <varlistentry>
  76. <term><parameter>--prefix=/tools</parameter></term>
  77. <listitem>
  78. <para>This tells the configure script to prepare to install the
  79. Binutils programs in the <filename class="directory">/tools</filename>
  80. directory.</para>
  81. </listitem>
  82. </varlistentry>
  83. <varlistentry>
  84. <term><parameter>--disable-nls</parameter></term>
  85. <listitem>
  86. <para>This disables internationalization as i18n is not needed for the
  87. temporary tools.</para>
  88. </listitem>
  89. </varlistentry>
  90. <varlistentry>
  91. <term><parameter>--disable-werror</parameter></term>
  92. <listitem>
  93. <para>This prevents the build from stopping in the event that there
  94. are warnings from the host's compiler.</para>
  95. </listitem>
  96. </varlistentry>
  97. </variablelist>
  98. <para>Continue with compiling the package:</para>
  99. <screen><userinput>make</userinput></screen>
  100. <para>Compilation is now complete. Ordinarily we would now run the
  101. test suite, but at this early stage the test suite framework (Tcl,
  102. Expect, and DejaGNU) is not yet in place. The benefits of running the
  103. tests at this point are minimal since the programs from this
  104. first pass will soon be replaced by those from the second.</para>
  105. <para>Create a symlink to ensure the sanity of our toolchain:</para>
  106. <screen><userinput>mkdir -v /tools/lib
  107. ln -sv lib /tools/lib64</userinput></screen>
  108. <para>Install the package:</para>
  109. <screen><userinput>make install</userinput></screen>
  110. <para>Finally, prepare the linker for the <quote>Adjusting</quote> phase
  111. later on:</para>
  112. <screen><userinput>make -C ld clean
  113. make -C ld LIB_PATH=/tools/lib
  114. cp -v ld/ld-new /tools/bin</userinput></screen>
  115. <variablelist>
  116. <title>The meaning of the make parameters:</title>
  117. <varlistentry>
  118. <term><parameter>-C ld clean</parameter></term>
  119. <listitem>
  120. <para>This tells the make program to remove all compiled
  121. files in the <filename class="directory">ld</filename>
  122. subdirectory.</para>
  123. </listitem>
  124. </varlistentry>
  125. <varlistentry>
  126. <term><parameter>-C ld LIB_PATH=/tools/lib</parameter></term>
  127. <listitem>
  128. <para>This option rebuilds everything in the <filename
  129. class="directory">ld</filename> subdirectory. Specifying the
  130. <envar>LIB_PATH</envar> Makefile variable on the command line
  131. allows us to override the default value and point it to the
  132. temporary tools location. The value of this variable specifies
  133. the linker's default library search path. This preparation is
  134. used later in the chapter.</para>
  135. </listitem>
  136. </varlistentry>
  137. </variablelist>
  138. </sect2>
  139. <sect2 role="content">
  140. <title/>
  141. <para>Details on this package are located in
  142. <xref linkend="contents-binutils" role="."/></para>
  143. </sect2>
  144. </sect1>