123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
- "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
- <!ENTITY % general-entities SYSTEM "../general.ent">
- %general-entities;
- ]>
- <sect1 id="ch-tools-binutils-pass2" role="wrap">
- <?dbhtml filename="binutils-pass2.html"?>
- <sect1info condition="script">
- <productname>binutils</productname>
- <productnumber>&binutils-version;</productnumber>
- <address>&binutils-url;</address>
- </sect1info>
- <title>Binutils-&binutils-version; - 第二遍</title>
- <indexterm zone="ch-tools-binutils-pass2">
- <primary sortas="a-Binutils">Binutils</primary>
- <secondary>tools, pass 2</secondary>
- </indexterm>
- <sect2 role="package">
- <title/>
- <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
- href="../chapter06/binutils.xml"
- xpointer="xpointer(/sect1/sect2[1]/para[1])"/>
- <segmentedlist>
- <segtitle>&buildtime;</segtitle>
- <segtitle>&diskspace;</segtitle>
- <seglistitem>
- <seg>&binutils-ch5p2-sbu;</seg>
- <seg>&binutils-ch5p2-du;</seg>
- </seglistitem>
- </segmentedlist>
- </sect2>
- <sect2 role="installation">
- <title>安装 Binutils</title>
- <para>再一次地,创建一个单独的构建目录:</para>
- <screen><userinput remap="pre">mkdir -v build
- cd build</userinput></screen>
- <para>准备安装 Binutils:</para>
- <screen><userinput remap="configure">CC=$LFS_TGT-gcc \
- AR=$LFS_TGT-ar \
- RANLIB=$LFS_TGT-ranlib \
- ../configure \
- --prefix=/tools \
- --disable-nls \
- --disable-werror \
- --with-lib-path=/tools/lib \
- --with-sysroot</userinput></screen>
- <variablelist>
- <title>配置选项的含义:</title>
- <varlistentry>
- <term><parameter>CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib</parameter></term>
- <listitem>
- <!--para>Because this is really a native build of Binutils, setting these
- variables ensures that the build system uses the cross-compiler and
- associated tools instead of the ones on the host system.</para-->
- <para>这次编译 Binutils 是本地编译而不是交叉编译,
- 设置这些变量可以强制构建系统使用交叉编译器和相关工具,
- 而不是宿主系统的编译器和工具。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--with-lib-path=/tools/lib</parameter></term>
- <listitem>
- <!--para>This tells the configure script to specify the library
- search path during the compilation of Binutils, resulting in
- <filename class="directory">/tools/lib</filename> being passed
- to the linker. This prevents the linker from searching through
- library directories on the host.</para-->
- <para>这个选项使得配置脚本在编译 Binutils 时指定库文件搜索目录,
- 将 <filename class="directory">/tools/lib</filename>
- 传递给链接器。这保证链接器不会搜索宿主系统的库文件目录。
- </para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>--with-sysroot</parameter></term>
- <listitem>
- <!--para>The sysroot feature enables the linker to find shared objects
- which are required by other shared objects explicitly included on the
- linker's command line. Without this, some packages may not build
- successfully on some hosts.</para-->
- <para>在链接时,某些共享对象可能要求其他共享对象,sysroot
- 特性允许链接器查找它们。如果不启用它,在某些宿主环境中,
- 一些软件包无法成功构建。</para>
- <note><title>译注</title>
- <para>这个选项看上去很奇怪,而且解释不够清晰。
- 译者查资料得知,
- 从 Binutils 2.17 起,为保证和动态链接器的一致性,
- <command>ld</command>在搜索 DT_NEEDED
- 要求的共享对象时,先搜索
- <filename>/etc/ld.so.conf</filename> 指定的目录,
- 再搜索配置时指定的默认目录。如果不启用 sysroot 功能,
- 且宿主系统使用了 <filename>/etc/ld.so.conf</filename>,
- 那么宿主环境中的共享对象会污染工具链,
- 进而导致一系列严重问题。
- 如果您不想使用这个看上去奇怪的选项,可以执行
- <userinput>touch /tools/etc/ld.so.conf</userinput>
- 创建一个空的 <filename>ld.so.conf</filename> 文件,
- 覆盖宿主系统的设置。参阅
- <ulink url="http://lists.linuxfromscratch.org/pipermail/lfs-dev/2012-December/067457.html">lfs-dev 列表中的讨论</ulink>,以及
- <ulink url="https://sourceware.org/bugzilla/show_bug.cgi?id=2290">ld/2290</ulink>。
- 另外 <filename>ld(1)</filename>
- 中关于这个搜索顺序的描述尚未更新。
- </para>
- </note>
- </listitem>
- </varlistentry>
- </variablelist>
- <para>编译该软件包:</para>
- <screen><userinput remap="make">make</userinput></screen>
- <para>安装该软件包:</para>
- <screen><userinput remap="install">make install</userinput></screen>
- <!--para>Now prepare the linker for the <quote>Re-adjusting</quote> phase in
- the next chapter:</para-->
- <para>现在,为下一章的 <quote>重新调整</quote> 阶段准备链接器:</para>
- <screen><userinput remap="adjust">make -C ld clean
- make -C ld LIB_PATH=/usr/lib:/lib
- cp -v ld/ld-new /tools/bin</userinput></screen>
- <variablelist>
- <title>make 命令参数的含义:</title>
- <varlistentry>
- <term><parameter>-C ld clean</parameter></term>
- <listitem>
- <!--para>This tells the make program to remove all compiled
- files in the <filename class="directory">ld</filename>
- subdirectory.</para-->
- <para>该选项告诉 make 程序移除
- <filename class="directory">ld</filename>
- 子目录中所有编译得到的文件。</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term><parameter>-C ld LIB_PATH=/usr/lib:/lib</parameter></term>
- <listitem>
- <!--para>This option rebuilds everything in the <filename
- class="directory">ld</filename> subdirectory. Specifying the
- <envar>LIB_PATH</envar> Makefile variable on the command line
- allows us to override the default value of the temporary tools
- and point it to the proper final path. The value of this variable
- specifies the linker's default library search path. This
- preparation is used in the next chapter.</para-->
- <para>该选项重新构建 <filename class="directory">ld</filename>
- 子目录中的一切。在命令行指定 <envar>LIB_PATH</envar>
- Makefile 变量,即可覆盖临时工具的默认值,
- 并将其指向正确的最终路径。
- 该变量的值指定链接器的默认库文件搜索路径,
- 这个准备好的链接器将在下一章使用。</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </sect2>
- <sect2 role="content">
- <title/>
- <para>该软件包的更多信息可以在
- <xref linkend="contents-binutils"/> 中找到。</para>
- </sect2>
- </sect1>
|