binutils-pass1.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <?xml version="1.0" encoding="UTF-8"?>
  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. <sect1info condition="script">
  10. <productname>binutils-pass1</productname>
  11. <productnumber>&binutils-version;</productnumber>
  12. <address>&binutils-url;</address>
  13. </sect1info>
  14. <title>Binutils-&binutils-version; - 第一遍</title>
  15. <indexterm zone="ch-tools-binutils-pass1">
  16. <primary sortas="a-Binutils">Binutils</primary>
  17. <secondary>tools, pass 1</secondary>
  18. </indexterm>
  19. <sect2 role="package">
  20. <title/>
  21. <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
  22. href="../chapter06/binutils.xml"
  23. xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
  24. <segmentedlist>
  25. <segtitle>&buildtime;</segtitle>
  26. <segtitle>&diskspace;</segtitle>
  27. <seglistitem>
  28. <seg>&binutils-ch5p1-sbu;</seg>
  29. <seg>&binutils-ch5p1-du;</seg>
  30. </seglistitem>
  31. </segmentedlist>
  32. </sect2>
  33. <sect2 role="installation">
  34. <title>安装交叉工具链中的 Binutils</title>
  35. <note><!--para>Go back and re-read the notes in the previous section.
  36. Understanding the notes labeled important will save you a lot
  37. of problems later.</para-->
  38. <para>返回并重新阅读上一节。仔细理解那些标为 <quote>重要</quote>
  39. 的说明,以防止之后出现问题。</para>
  40. </note>
  41. <!--para>It is important that Binutils be the first package compiled
  42. because both Glibc and GCC perform various tests on the available
  43. linker and assembler to determine which of their own features to
  44. enable.</para-->
  45. <para>首先构建 Binutils 相当重要,
  46. 因为 Glibc 和 GCC 都会对可用的链接器和汇编器进行测试,
  47. 以决定可以启用它们自带的哪些特性。</para>
  48. <!--para>The Binutils documentation recommends building Binutils
  49. in a dedicated build directory:</para-->
  50. <para>Binutils 文档推荐在一个专用的目录中构建 Binutils:</para>
  51. <screen><userinput remap="pre">mkdir -v build
  52. cd build</userinput></screen>
  53. <note>
  54. <!--para>In order for the SBU values listed in the rest of the book
  55. to be of any use, measure the time it takes to build this package from
  56. the configuration, up to and including the first install. To achieve
  57. this easily, wrap the commands in a <command>time</command>
  58. command like this: <userinput>time { ./configure ... &amp;&amp; ...
  59. &amp;&amp; make install; }</userinput>.</para-->
  60. <para>为了衡量本书其余部分使用的 SBU 值,
  61. 需要测量本软件包从配置开始直到第一次安装花费的时间。
  62. 为了容易地完成测量,可以将命令包装在 <command>time</command>
  63. 命令中,就像这样:
  64. <userinput>time {./configure ... &amp;&amp; ... &amp;&amp;
  65. make install; }</userinput>。</para>
  66. </note>
  67. <note><!--para>The approximate build SBU values and required disk space
  68. in Chapter&nbsp;5 does not include test suite data.</para-->
  69. <para>第 5 章中估计的 SBU 值和所需磁盘空间都不包含测试套件的数据。
  70. </para>
  71. </note>
  72. <para>现在,准备编译 Binutils :</para>
  73. <screen><userinput remap="configure">../configure --prefix=/tools \
  74. --with-sysroot=$LFS \
  75. --with-lib-path=/tools/lib \
  76. --target=$LFS_TGT \
  77. --disable-nls \
  78. --disable-werror</userinput></screen>
  79. <variablelist>
  80. <title>配置选项的含义:</title>
  81. <varlistentry>
  82. <term><parameter>--prefix=/tools</parameter></term>
  83. <listitem>
  84. <para>这告诉配置脚本准备将 Binutils 程序安装在
  85. <filename class="directory">/tools</filename> 目录中。</para>
  86. </listitem>
  87. </varlistentry>
  88. <varlistentry>
  89. <term><parameter>--with-sysroot=$LFS</parameter></term>
  90. <listitem>
  91. <para>该选项告诉构建系统,交叉编译时在 $LFS 中寻找目标系统的库。
  92. </para>
  93. </listitem>
  94. </varlistentry>
  95. <varlistentry>
  96. <term><parameter>--with-lib-path=/tools/lib</parameter></term>
  97. <listitem>
  98. <para>该选项指定链接器应该使用的库文件搜索路径。</para>
  99. </listitem>
  100. </varlistentry>
  101. <varlistentry>
  102. <term><envar>--target=$LFS_TGT</envar></term>
  103. <listitem>
  104. <para>由于 <envar>LFS_TGT</envar> 变量中的机器描述和
  105. <command>config.guess</command> 脚本的输出略有不同,
  106. 这个开关使得 <command>configure</command> 脚本调整 Binutils
  107. 的构建系统,以构建交叉链接器。</para>
  108. </listitem>
  109. </varlistentry>
  110. <varlistentry>
  111. <term><parameter>--disable-nls</parameter></term>
  112. <listitem>
  113. <para>该选项禁用临时工具不需要的国际化功能。</para>
  114. </listitem>
  115. </varlistentry>
  116. <varlistentry>
  117. <term><parameter>--disable-werror</parameter></term>
  118. <listitem>
  119. <para>该选项防止宿主系统编译器警告导致构建失败。</para>
  120. </listitem>
  121. </varlistentry>
  122. </variablelist>
  123. <para>然后编译该软件包:</para>
  124. <screen><userinput remap="make">make</userinput></screen>
  125. <!--para>Compilation is now complete. Ordinarily we would now run the
  126. test suite, but at this early stage the test suite framework (Tcl,
  127. Expect, and DejaGNU) is not yet in place. The benefits of running the
  128. tests at this point are minimal since the programs from this
  129. first pass will soon be replaced by those from the second.</para-->
  130. <para>现在编译已经完成,一般来说我们应该执行测试套件,
  131. 但在当前的早期构建阶段,测试套件框架 (Tcl、Expect 和 DejaGNU)
  132. 尚不可用。另外,由于第一遍构建的程序很快会被第二遍构建的程序替代,
  133. 运行测试的收益极小。</para>
  134. <para>如果在 x86_64 上编译,创建一个符号链接以保证工具链的完整性:
  135. </para>
  136. <screen><userinput remap="install">case $(uname -m) in
  137. x86_64) mkdir -v /tools/lib &amp;&amp; ln -sv lib /tools/lib64 ;;
  138. esac</userinput></screen>
  139. <para>安装该软件包:</para>
  140. <screen><userinput remap="install">make install</userinput></screen>
  141. </sect2>
  142. <sect2 role="content">
  143. <title/>
  144. <para>这个软件包的细节在
  145. <xref linkend="contents-binutils"/> 中可以找到。</para>
  146. </sect2>
  147. </sect1>