Files
master/chapter05/binutils-pass1.html
2015-05-23 18:50:06 +08:00

263 lines
9.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content=
"application/xhtml+xml; charset=utf-8" />
<title>
5.4.&nbsp;Binutils-2.25 - 第1遍
</title>
<link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
<link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css"
media="print" />
</head>
<body class="lfs" id="lfs-7.7-systemd">
<div class="navheader">
<h4>
Linux From Scratch - Version 7.7-systemd
</h4>
<h3>
第五章&nbsp;构建临时系统
</h3>
<ul>
<li class="prev">
<a accesskey="p" href="generalinstructions.html" title=
"通用编译指南">上一页</a>
<p>
通用编译指南
</p>
</li>
<li class="next">
<a accesskey="n" href="gcc-pass1.html" title=
"GCC-4.9.2 - 第一遍">下一页</a>
<p>
GCC-4.9.2 - 第一遍
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter05.html" title=
"第五章&nbsp;构建临时系统">返回</a>
</li>
<li class="home">
<a accesskey="h" href="../index.html" title=
"Linux From Scratch - Version 7.7-systemd">主页</a>
</li>
</ul>
</div>
<div class="wrap" lang="en" xml:lang="en">
<h1 class="sect1">
<a id="ch-tools-binutils-pass1" name=
"ch-tools-binutils-pass1"></a>5.4. Binutils-2.25 - 第一遍
</h1>
<div class="package" lang="en" xml:lang="en">
<p>
Binutils 软件包包括一个链接器,汇编器和其它处理目标文件的工具。
</p>
<div class="segmentedlist">
<div class="seglistitem">
<div class="seg">
<strong class="segtitle">大概编译时间:</strong>
<span class="segbody">1 SBU</span>
</div>
<div class="seg">
<strong class="segtitle">所需磁盘空间:</strong>
<span class="segbody">545 MB</span>
</div>
</div>
</div>
</div>
<div class="installation" lang="en" xml:lang="en">
<h2 class="sect2">
5.4.1. 安装交叉编译的 Binutils
</h2>
<div class="admon note">
<img alt="[Note]" src="../images/note.png" />
<h3>
注意
</h3>
<p>
返回前面章节重新阅读注意事项。了解标记重要的注意事项能在后面帮你节省很多问题。
</p>
</div>
<p>
首先编译 Binutils 软件包很重要,因为 Glibc 和 GCC 会对可用的链接器和
汇编器执行各种测试以决定启用它们自己的哪些功能。
</p>
<p>
Binutils 手册建议在源码目录之外一个专门的编译目录里面编译 Binutils
</p>
<pre class="userinput">
<kbd class="command">mkdir -v ../binutils-build
cd ../binutils-build</kbd>
</pre>
<div class="admon note">
<img alt="[Note]" src="../images/note.png" />
<h3>
注意
</h3>
<p>
为了能使用本书中其余部分列出的 SBU 值,测量从配置到包括第一次安装在内的编译时间。
为了轻松的做到这点,用类似 <strong class="userinput"><code>time { ./configure ... &amp;&amp;
... &amp;&amp; make install; }</code></strong> 的命令包装 <span class=
"command"><strong>time</strong></span> 命令。
</p>
</div>
<div class="admon note">
<img alt="[Note]" src="../images/note.png" />
<h3>
注意
</h3>
<p>
第五章中大概编译 SBU 值和所需磁盘空间不包括测试套件数据。
</p>
</div>
<p>
现在准备编译 Binutils
</p>
<pre class="userinput">
<kbd class="command">../binutils-2.25/configure \
--prefix=/tools \
--with-sysroot=$LFS \
--with-lib-path=/tools/lib \
--target=$LFS_TGT \
--disable-nls \
--disable-werror</kbd>
</pre>
<div class="variablelist">
<p class="title">
<strong>配置选项的含义:</strong>
</p>
<dl class="variablelist">
<dt>
<span class="term"><em class=
"parameter"><code>--prefix=/tools</code></em></span>
</dt>
<dd>
<p>
告诉配置脚本将 Binutils 程序安装到 <code class="filename">/tools</code> 文件夹。
</p>
</dd>
<dt>
<span class="term"><em class=
"parameter"><code>--with-sysroot=$LFS</code></em></span>
</dt>
<dd>
<p>
用于交叉编译,告诉编译系统需要 $LFS 的目标系统库。
</p>
</dd>
<dt>
<span class="term"><em class=
"parameter"><code>--with-lib-path=/tools/lib</code></em></span>
</dt>
<dd>
<p>
指定配置链接器应该使用的库路径。
</p>
</dd>
<dt>
<span class="term"><code class=
"envar">--target=$LFS_TGT</code></span>
</dt>
<dd>
<p>
因为<code class=
"envar">LFS_TGT</code> 变量中的机器描述和<span class=
"command"><strong>config.guess</strong></span> 脚本返回的值略有不同,
这个选项会告诉 <span class=
"command"><strong>configure</strong></span> 脚本调整 Binutils 的编译系统
编译一个交叉链接器。
</p>
</dd>
<dt>
<span class="term"><em class=
"parameter"><code>--disable-nls</code></em></span>
</dt>
<dd>
<p>
这会禁止国际化,因为国际化对临时工具来说没有必要。
</p>
</dd>
<dt>
<span class="term"><em class=
"parameter"><code>--disable-werror</code></em></span>
</dt>
<dd>
<p>
这会防止有来自主机编译器的警告事件时停止编译。
</p>
</dd>
</dl>
</div>
<p>
继续编译软件包:
</p>
<pre class="userinput">
<kbd class="command">make</kbd>
</pre>
<p>
现在编译完成了。通常现在我们会运行测试套件,但在这初期测试套件框架
(Tcl,Expect, 和 DejaGNU) 还没有就绪。在此进行测试的好处是很小的,
因为第一遍编译的程序很快会被第二遍的代替。
</p>
<p>
如果是在 x86_64 上编译,创建符号链接,以确保工具链的完整性:
</p>
<pre class="userinput">
<kbd class="command">case $(uname -m) in
x86_64) mkdir -v /tools/lib &amp;&amp; ln -sv lib /tools/lib64 ;;
esac</kbd>
</pre>
<p>
安装软件包:
</p>
<pre class="userinput">
<kbd class="command">make install</kbd>
</pre>
</div>
<div class="content" lang="en" xml:lang="en">
<p>
该软件包的详细信息在 <a class="xref" href="../chapter06/binutils.html#contents-binutils" title=
"6.13.2.&nbsp;Binutils 的内容">6.13.2,
&ldquo;Binutils 的内容。&rdquo;</a>
</p>
</div>
</div>
<div class="navfooter">
<div class="book">
<div class="titlepage">
<div class="author">
<span class="firstname">翻译团队:<a href="http://lctt.github.io/" target="_blank">LCTT</a></span>
<span class="surname">译者/校对:<a href="http://github.com/ictlyh" target="_blank">ictlyh</a>,</span>
</div>
</div>
</div>
<ul>
<li class="prev">
<a accesskey="p" href="generalinstructions.html" title=
"通用编译指南">上一页</a>
<p>
通用编译指南
</p>
</li>
<li class="next">
<a accesskey="n" href="gcc-pass1.html" title=
"GCC-4.9.2 - 第1遍">下一页</a>
<p>
GCC-4.9.2 - 第1遍
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter05.html" title=
"第五章&nbsp;构建临时系统">返回</a>
</li>
<li class="home">
<a accesskey="h" href="../index.html" title=
"Linux From Scratch - Version 7.7-systemd">主页</a>
</li>
</ul>
</div>
</body>
</html>