toolchaintechnotes.po 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. msgid ""
  2. msgstr ""
  3. "Project-Id-Version: PACKAGE VERSION\n"
  4. "POT-Creation-Date: 2020-06-21 23:42+0800\n"
  5. "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
  6. "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
  7. "Language-Team: LANGUAGE <LL@li.org>\n"
  8. "Language: zh_CN\n"
  9. "MIME-Version: 1.0\n"
  10. "Content-Type: text/plain; charset=UTF-8\n"
  11. "Content-Transfer-Encoding: 8bit\n"
  12. "X-Generator: Translate Toolkit 2.2.5\n"
  13. #. type: Content of: <sect1><title>
  14. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:11
  15. msgid "Toolchain Technical Notes"
  16. msgstr "工具链技术说明"
  17. #. type: Content of: <sect1><para>
  18. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:13
  19. msgid ""
  20. "This section explains some of the rationale and technical details behind the "
  21. "overall build method. It is not essential to immediately understand "
  22. "everything in this section. Most of this information will be clearer after "
  23. "performing an actual build. This section can be referred to at any time "
  24. "during the process."
  25. msgstr ""
  26. "本节综合地解释构建方法中的逻辑和技术细节。您现在并不需要立刻理解本节的所有内"
  27. "容,在实际进行构建的过程中,可以更清晰地理解本节的信息。在整个构建过程中,您"
  28. "随时可以回来翻阅本节。"
  29. #. type: Content of: <sect1><para>
  30. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:19
  31. msgid ""
  32. "The overall goal of <xref linkend=\"chapter-cross-tools\"/> and <xref "
  33. "linkend=\"chapter-temporary-tools\"/> is to produce a temporary area that "
  34. "contains a known-good set of tools that can be isolated from the host "
  35. "system. By using <command>chroot</command>, the commands in the remaining "
  36. "chapters will be contained within that environment, ensuring a clean, "
  37. "trouble-free build of the target LFS system. The build process has been "
  38. "designed to minimize the risks for new readers and to provide the most "
  39. "educational value at the same time."
  40. msgstr ""
  41. "<xref linkend=\"chapter-cross-tools\"/>和<xref linkend=\"chapter-temporary-"
  42. "tools\"/>的总目标是构造一个临时环境,它包含一组可靠的,能够与宿主系统完全分离"
  43. "的工具。这样,通过使用 <command>chroot</command> 命令,其余各章中执行的命令就"
  44. "被限制在这个临时环境中。这确保我们能够干净、顺利地构建 LFS 系统。整个构建过程"
  45. "被精心设计,以尽量降低新读者可能面临的风险,同时提供尽可能多的教育价值。"
  46. #. type: Content of: <sect1><para>
  47. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:28
  48. msgid ""
  49. "The build process is based on the process of <emphasis>cross-compilation</"
  50. "emphasis>. Cross-compilation is normally used for building a compiler and "
  51. "its toolchain for a machine different from the one that is used for the "
  52. "build. This is not strictly needed for LFS, since the machine where the new "
  53. "system will run is the same as the one used for the build. But cross-"
  54. "compilation has the great advantage that anything that is cross-compiled "
  55. "cannot depend on the host environment."
  56. msgstr ""
  57. "构建过程是基于<emphasis>交叉编译</emphasis>过程的。交叉编译通常被用于为一台与"
  58. "本机完全不同的计算机构建编译器及其工具链。这对于 LFS 并不严格必要,因为新系统"
  59. "运行的机器就是构建它时使用的。但是,交叉编译拥有一项重要优势,即任何交叉编译"
  60. "产生的程序都不可能依赖于宿主环境。"
  61. #. type: Content of: <sect1><sect2><title>
  62. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:38
  63. msgid "About Cross-Compilation"
  64. msgstr "关于交叉编译"
  65. #. type: Content of: <sect1><sect2><para>
  66. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:40
  67. msgid ""
  68. "Cross-compilation involves some concepts that deserve a section on their "
  69. "own. Although this section may be omitted in a first reading, it is strongly "
  70. "suggested to come back to it later in order to get a full grasp of the build "
  71. "process."
  72. msgstr ""
  73. "交叉编译涉及一些概念,值得专门用一节讨论。尽管您可以在初次阅读时跳过本节,但"
  74. "强烈建议您之后回头阅读本节,以完全掌握构建过程。"
  75. #. type: Content of: <sect1><sect2><para>
  76. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:45
  77. msgid "Let us first define some terms used in this context:"
  78. msgstr "首先我们定义讨论交叉编译时常用的术语:"
  79. #. type: Content of: <sect1><sect2><variablelist><varlistentry><term>
  80. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:48
  81. msgid "build"
  82. msgstr "build"
  83. #. type: Content of: <sect1><sect2><variablelist><varlistentry><listitem><para>
  84. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:49
  85. msgid ""
  86. "is the machine where we build programs. Note that this machine is referred "
  87. "to as the <quote>host</quote> in other sections."
  88. msgstr ""
  89. "指构建程序时使用的机器。注意在某些其他章节,这台机器被称为<quote>host</"
  90. "quote>(宿主)。"
  91. #. type: Content of: <sect1><sect2><variablelist><varlistentry><term>
  92. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:54
  93. msgid "host"
  94. msgstr "host"
  95. #. type: Content of: <sect1><sect2><variablelist><varlistentry><listitem><para>
  96. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:55
  97. msgid ""
  98. "is the machine/system where the built programs will run. Note that this use "
  99. "of <quote>host</quote> is not the same as in other sections."
  100. msgstr ""
  101. "指将来会运行被构建的程序的机器。注意这里说的<quote>host</quote>与其他章节使用"
  102. "的“宿主”(host) 一词不同。"
  103. #. type: Content of: <sect1><sect2><variablelist><varlistentry><term>
  104. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:60
  105. msgid "target"
  106. msgstr "target"
  107. #. type: Content of: <sect1><sect2><variablelist><varlistentry><listitem><para>
  108. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:61
  109. msgid ""
  110. "is only used for compilers. It is the machine the compiler produces code "
  111. "for. It may be different from both build and host."
  112. msgstr ""
  113. "只有编译器使用这个术语。编译器为这台机器产生代码。它可能和 build 与 host 都不"
  114. "同。"
  115. #. type: Content of: <sect1><sect2><para>
  116. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:68
  117. msgid ""
  118. "As an example, let us imagine the following scenario (sometimes referred to "
  119. "as <quote>Canadian Cross</quote>): we may have a compiler on a slow machine "
  120. "only, let's call the machine A, and the compiler ccA. We may have also a "
  121. "fast machine (B), but with no compiler, and we may want to produce code for "
  122. "another slow machine (C). To build a compiler for machine C, we would have "
  123. "three stages:"
  124. msgstr ""
  125. "例如,我们考虑下列场景 (有时称为<quote>Canadian Cross</quote>):我们仅在一台"
  126. "运行缓慢的机器上有编译器,称这台机器为 A,这个编译器为 ccA。我们还有一台运行"
  127. "较快的机器 (B),但它没有安装编译器,而我们希望为另一台缓慢的机器 (C) 生成代"
  128. "码。如果要为 C 构建编译器,可以通过三个阶段完成:"
  129. #. type: Content of: <sect1><sect2><informaltable><tgroup><thead><row><entry>
  130. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:83
  131. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:117
  132. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:187
  133. msgid "Stage"
  134. msgstr "阶段"
  135. #. type: Content of: <sect1><sect2><informaltable><tgroup><thead><row><entry>
  136. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:83
  137. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:117
  138. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:187
  139. msgid "Build"
  140. msgstr "Build"
  141. #. type: Content of: <sect1><sect2><informaltable><tgroup><thead><row><entry>
  142. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:83
  143. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:117
  144. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:187
  145. msgid "Host"
  146. msgstr "Host"
  147. #. type: Content of: <sect1><sect2><informaltable><tgroup><thead><row><entry>
  148. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:84
  149. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:118
  150. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:188
  151. msgid "Target"
  152. msgstr "Target"
  153. #. type: Content of: <sect1><sect2><informaltable><tgroup><thead><row><entry>
  154. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:84
  155. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:118
  156. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:188
  157. msgid "Action"
  158. msgstr "操作描述"
  159. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  160. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:88
  161. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:192
  162. msgid "1"
  163. msgstr "1"
  164. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  165. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:88
  166. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:92
  167. msgid "A"
  168. msgstr "A"
  169. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  170. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:88
  171. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:92
  172. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:96
  173. msgid "B"
  174. msgstr "B"
  175. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  176. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:89
  177. msgid "build cross-compiler cc1 using ccA on machine A"
  178. msgstr "在机器 A 上,使用 ccA 构建交叉编译器 cc1"
  179. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  180. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:92
  181. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:196
  182. msgid "2"
  183. msgstr "2"
  184. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  185. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:92
  186. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:96
  187. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:122
  188. msgid "C"
  189. msgstr "C"
  190. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  191. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:93
  192. msgid "build cross-compiler cc2 using cc1 on machine A"
  193. msgstr "在机器 A 上,使用 cc1 构建交叉编译器 cc2"
  194. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  195. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:96
  196. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:200
  197. msgid "3"
  198. msgstr "3"
  199. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  200. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:97
  201. msgid "build compiler ccC using cc2 on machine B"
  202. msgstr "在机器 B 上,使用 cc2 构建交叉编译器 ccC"
  203. #. type: Content of: <sect1><sect2><para>
  204. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:103
  205. msgid ""
  206. "Then, all the other programs needed by machine C can be compiled using cc2 "
  207. "on the fast machine B. Note that unless B can run programs produced for C, "
  208. "there is no way to test the built programs until machine C itself is "
  209. "running. For example, for testing ccC, we may want to add a fourth stage:"
  210. msgstr ""
  211. "这样,我们可以为机器 C 使用 cc2 在快速的机器 B 上构建所有其他程序。注意除非 "
  212. "B 能运行为 C 编译的程序,我们无法测试编译得到的程序,直到在 C 上运行它。例"
  213. "如,如果要测试 ccC,我们可以增加第四个阶段:"
  214. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  215. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:122
  216. msgid "4"
  217. msgstr "4"
  218. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  219. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:123
  220. msgid "rebuild and test ccC using itself on machine C"
  221. msgstr "在机器 C 上,用 ccC 重新构建它本身,并测试"
  222. #. type: Content of: <sect1><sect2><para>
  223. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:129
  224. msgid ""
  225. "In the example above, only cc1 and cc2 are cross-compilers, that is, they "
  226. "produce code for a machine different from the one they are run on. The "
  227. "other compilers ccA and ccC produce code for the machine they are run on. "
  228. "Such compilers are called <emphasis>native</emphasis> compilers."
  229. msgstr ""
  230. "在上面的例子中,只有 cc1 和 cc2 是交叉编译器,它们为与它们本身运行的机器不同"
  231. "的机器产生代码。而另外的编译器 ccA 和 ccC 为它们本身运行的机器产生代码,它们"
  232. "称为<emphasis>本地</emphasis>编译器。"
  233. #. type: Content of: <sect1><sect2><title>
  234. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:137
  235. msgid "Implementation of Cross-Compilation for LFS"
  236. msgstr "LFS 的交叉编译实现"
  237. #. type: Content of: <sect1><sect2><note><para>
  238. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:140
  239. msgid ""
  240. "Almost all the build systems use names of the form cpu-vendor-kernel-os "
  241. "referred to as the machine triplet. An astute reader may wonder why a "
  242. "<quote>triplet</quote> refers to a four component name. The reason is "
  243. "history: initially, three component names were enough to designate "
  244. "unambiguously a machine, but with new machines and systems appearing, that "
  245. "proved insufficient. The word <quote>triplet</quote> remained. A simple way "
  246. "to determine your machine triplet is to run the <command>config.guess</"
  247. "command> script that comes with the source for many packages. Unpack the "
  248. "binutils sources and run the script: <userinput>./config.guess</userinput> "
  249. "and note the output. For example, for a 32-bit Intel processor the output "
  250. "will be <emphasis>i686-pc-linux-gnu</emphasis>. On a 64-bit system it will "
  251. "be <emphasis>x86_64-pc-linux-gnu</emphasis>."
  252. msgstr ""
  253. "几乎所有构建系统都使用形如 CPU-供应商-内核-操作系统,称为三元组的名称表示目标"
  254. "机器。好奇的读者可能感到奇怪,为什么一个<quote>三元组</quote>却包含四个部分。"
  255. "这是历史遗留的:最早,三个部分就足以无歧义地描述一台机器。但是随着新的机器和"
  256. "系统不断出现,最终证明三个部分是不够的。然而,<quote>三元组</quote>这个术语保"
  257. "留了下来。有一种简单方法可以获得您的机器的三元组,即运行许多软件包附带的 "
  258. "<command>config.guess</command> 脚本。解压缩 Binutils 源码,然后运行脚本:"
  259. "<userinput>./config.guess</userinput>,观察输出。例如,对于 32 位 Intel 处理"
  260. "器,输出应该是 <emphasis>i686-pc-linux-gnu</emphasis>,而对于 64 位系统输出应"
  261. "该是 <emphasis>x86_64-pc-linux-gnu</emphasis>。"
  262. #. type: Content of: <sect1><sect2><note><para>
  263. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:154
  264. msgid ""
  265. "Also be aware of the name of the platform's dynamic linker, often referred "
  266. "to as the dynamic loader (not to be confused with the standard linker "
  267. "<command>ld</command> that is part of binutils). The dynamic linker provided "
  268. "by Glibc finds and loads the shared libraries needed by a program, prepares "
  269. "the program to run, and then runs it. The name of the dynamic linker for a "
  270. "32-bit Intel machine will be <filename class=\"libraryfile\">ld-linux.so.2</"
  271. "filename> (<filename class=\"libraryfile\">ld-linux-x86-64.so.2</filename> "
  272. "for 64-bit systems). A sure-fire way to determine the name of the dynamic "
  273. "linker is to inspect a random binary from the host system by running: "
  274. "<userinput>readelf -l &lt;name of binary&gt; | grep interpreter</userinput> "
  275. "and noting the output. The authoritative reference covering all platforms is "
  276. "in the <filename>shlib-versions</filename> file in the root of the Glibc "
  277. "source tree."
  278. msgstr ""
  279. "另外注意平台的动态链接器的名称,它又被称为动态加载器 (不要和 Binutils 中的普"
  280. "通链接器 <command>ld</command> 混淆)。动态链接器由 Glibc 提供,它寻找并加载程"
  281. "序所需的共享库,为程序运行做好准备,然后运行程序。在 32 位 Intel 机器上动态链"
  282. "接器的名称是 <filename class=\"libraryfile\">ld-linux.so.2</filename> (在 64 "
  283. "位系统上是 <filename class=\"libraryfile\">ld-linux-x86-64.so.2</filename>)。"
  284. "一个确定动态链接器名称的准确方法是从宿主系统找一个二进制可执行文件,然后执"
  285. "行:<userinput>readelf -l &lt;二进制文件名&gt; | grep interpreter</"
  286. "userinput> 并观察输出。包含所有平台的权威参考可以在 Glibc 源码树根目录的 "
  287. "<filename>shlib-versions</filename> 文件中找到。"
  288. #. type: Content of: <sect1><sect2><para>
  289. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:170
  290. msgid ""
  291. "In order to fake a cross compilation, the name of the host triplet is "
  292. "slightly adjusted by changing the &quot;vendor&quot; field in the "
  293. "<envar>LFS_TGT</envar> variable. We also use the <parameter>--with-sysroot</"
  294. "parameter> option when building the cross linker and cross compiler to tell "
  295. "them where to find the needed host files. This ensures that none of the "
  296. "other programs built in <xref linkend=\"chapter-temporary-tools\"/> can link "
  297. "to libraries on the build machine. Only two stages are mandatory, and one "
  298. "more for tests:"
  299. msgstr ""
  300. "为了将本机伪装成交叉编译目标机器,我们在 <envar>LFS_TGT</envar> 变量中,对宿"
  301. "主系统三元组的 &quot;vendor&quot; 域进行修改。我们还会在构建交叉链接器和交叉"
  302. "编译器时使用 <parameter>--with-sysroot</parameter> 选项,指定查找所需的 host "
  303. "系统文件的位置。这保证在<xref linkend=\"chapter-temporary-tools\"/>中的其他程"
  304. "序在构建时不会链接到宿主 (build) 系统的库。前两个阶段是必要的,第三个阶段可以"
  305. "用于测试:"
  306. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  307. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:192
  308. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:196
  309. msgid "pc"
  310. msgstr "pc"
  311. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  312. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:192
  313. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:196
  314. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:200
  315. msgid "lfs"
  316. msgstr "lfs"
  317. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  318. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:193
  319. msgid "build cross-compiler cc1 using cc-pc on pc"
  320. msgstr "在 pc 上使用 cc-pc 构建交叉编译器 cc1"
  321. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  322. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:197
  323. msgid "build compiler cc-lfs using cc1 on pc"
  324. msgstr "在 pc 上使用 cc1 构建 cc-lfs"
  325. #. type: Content of: <sect1><sect2><informaltable><tgroup><tbody><row><entry>
  326. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:201
  327. msgid "rebuild and test cc-lfs using itself on lfs"
  328. msgstr "在 lfs 上使用 cc-lfs 重新构建并测试它本身"
  329. #. type: Content of: <sect1><sect2><para>
  330. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:207
  331. msgid ""
  332. "In the above table, <quote>on pc</quote> means the commands are run on a "
  333. "machine using the already installed distribution. <quote>On lfs</quote> "
  334. "means the commands are run in a chrooted environment."
  335. msgstr ""
  336. "在上表中,<quote>在 pc 上</quote> 意味着命令在已经安装好的发行版中执行。"
  337. "<quote>在 lfs 上</quote> 意味着命令在 chroot 环境中执行。"
  338. #. type: Content of: <sect1><sect2><para>
  339. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:211
  340. msgid ""
  341. "Now, there is more about cross-compiling: the C language is not just a "
  342. "compiler, but also defines a standard library. In this book, the GNU C "
  343. "library, named glibc, is used. This library must be compiled for the lfs "
  344. "machine, that is, using the cross compiler cc1. But the compiler itself "
  345. "uses an internal library implementing complex instructions not available in "
  346. "the assembler instruction set. This internal library is named libgcc, and "
  347. "must be linked to the glibc library to be fully functional! Furthermore, the "
  348. "standard library for C++ (libstdc++) also needs being linked to glibc. The "
  349. "solution to this chicken and egg problem is to first build a degraded cc1 "
  350. "based libgcc, lacking some functionalities such as threads and exception "
  351. "handling, then build glibc using this degraded compiler (glibc itself is not "
  352. "degraded), then build libstdc++. But this last library will lack the same "
  353. "functionalities as libgcc."
  354. msgstr ""
  355. "现在,关于交叉编译,还有更多要处理的问题:C 语言并不仅仅由一个编译器实现,它"
  356. "还规定了一个标准库。在本书中,我们使用 GNU C 运行库,即 glibc。它必须为 lfs "
  357. "目标机器使用交叉编译器 cc1 编译。但是,编译器本身使用一个库,实现汇编指令集并"
  358. "不支持的一些复杂指令。这个内部库称为 libgcc,它必须链接到 glibc 库才能实现完"
  359. "整功能!另外,C++ 标准库 (libstdc++) 也必须链接到 glibc。为了解决这个”先有鸡"
  360. "还是先有蛋“的问题,只能先构建一个降级的 cc1,它的 libgcc 缺失线程和异常等功"
  361. "能,再用这个降级的编译器构建 glibc (这不会导致 glibc 缺失功能),再构建 "
  362. "libstdc++。但是这种方法构建的 libstdc++ 和 libgcc 一样,会缺失一些功能。"
  363. #. type: Content of: <sect1><sect2><para>
  364. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:226
  365. msgid ""
  366. "This is not the end of the story: the conclusion of the preceding paragraph "
  367. "is that cc1 is unable to build a fully functional libstdc++, but this is the "
  368. "only compiler available for building the C/C++ libraries during stage 2! Of "
  369. "course, the compiler built during stage 2, cc-lfs, would be able to build "
  370. "those libraries, but (1) the build system of GCC does not know that it is "
  371. "usable on pc, and (2) using it on pc would be at risk of linking to the pc "
  372. "libraries, since cc-lfs is a native compiler. So we have to build libstdc++ "
  373. "later, in chroot."
  374. msgstr ""
  375. "讨论还没有结束:上面一段的结论是 cc1 无法构建功能完整的 libstdc++,但这是我们"
  376. "在阶段 2 构建 C/C++ 库时唯一可用的编译器!当然,在阶段 2 中构建的编译器 cc-"
  377. "lfs 将会可以构建这些库,但是 (1) GCC 构建系统不知道这个编译器在 pc 上可以使"
  378. "用,而且 (2) 它是一个本地编译器,因此在 pc 上使用它可能产生链接到 pc (宿主系"
  379. "统) 库的风险。因此我们必须在进入 chroot 后再次构建 libstdc++。"
  380. #. type: Content of: <sect1><sect2><title>
  381. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:239
  382. msgid "Other procedural details"
  383. msgstr "构建过程的其他细节"
  384. #. type: Content of: <sect1><sect2><para>
  385. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:241
  386. msgid ""
  387. "The cross-compiler will be installed in a separate <filename class="
  388. "\"directory\">$LFS/tools</filename> directory, since it will not be part of "
  389. "the final system."
  390. msgstr ""
  391. "交叉编译器会被安装在独立的 <filename class=\"directory\">$LFS/tools</"
  392. "filename> 目录,因为它不属于最终构建的系统。"
  393. #. type: Content of: <sect1><sect2><para>
  394. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:245
  395. msgid ""
  396. "Binutils is installed first because the <command>configure</command> runs of "
  397. "both GCC and Glibc perform various feature tests on the assembler and linker "
  398. "to determine which software features to enable or disable. This is more "
  399. "important than one might first realize. An incorrectly configured GCC or "
  400. "Glibc can result in a subtly broken toolchain, where the impact of such "
  401. "breakage might not show up until near the end of the build of an entire "
  402. "distribution. A test suite failure will usually highlight this error before "
  403. "too much additional work is performed."
  404. msgstr ""
  405. "我们首先安装 Binutils 。这是由于 GCC 和 Glibc 的 <command>configure</"
  406. "command> 脚本首先测试汇编器和链接器的一些特性,以决定启用或禁用一些软件特性。"
  407. "初看起来这并不重要,但没有正确配置的 GCC 或者 Glibc 可以导致工具链中潜伏的故"
  408. "障。这些故障可能到整个构建过程快要结束时才突然爆发,不过在花费大量无用功之"
  409. "前,测试套件的失败可以将这类错误凸显出来。"
  410. #. type: Content of: <sect1><sect2><para>
  411. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:254
  412. msgid ""
  413. "Binutils installs its assembler and linker in two locations, <filename class="
  414. "\"directory\">$LFS/tools/bin</filename> and <filename class=\"directory\">"
  415. "$LFS/tools/$LFS_TGT/bin</filename>. The tools in one location are hard "
  416. "linked to the other. An important facet of the linker is its library search "
  417. "order. Detailed information can be obtained from <command>ld</command> by "
  418. "passing it the <parameter>--verbose</parameter> flag. For example, <command>"
  419. "$LFS_TGT-ld --verbose | grep SEARCH</command> will illustrate the current "
  420. "search paths and their order. It shows which files are linked by "
  421. "<command>ld</command> by compiling a dummy program and passing the "
  422. "<parameter>--verbose</parameter> switch to the linker. For example, <command>"
  423. "$LFS_TGT-gcc dummy.c -Wl,--verbose 2&gt;&amp;1 | grep succeeded</command> "
  424. "will show all the files successfully opened during the linking."
  425. msgstr ""
  426. "Binutils 将汇编器和链接器安装在两个位置,一个是 <filename class=\"directory"
  427. "\">$LFS/tools/bin</filename>,另一个是 <filename class=\"directory\">$LFS/"
  428. "tools/$LFS_TGT/bin</filename>。这两个位置中的工具互为硬链接。链接器的一项重要"
  429. "属性是它搜索库的顺序,通过向 <command>ld</command> 命令加入 <parameter>--"
  430. "verbose</parameter> 参数,可以得到关于搜索路径的详细信息。例如,"
  431. "<userinput>ld --verbose | grep SEARCH</userinput> 会输出当前的搜索路径及其顺"
  432. "序。此外,通过编译一个样品 (dummy) 程序并向链接器 <command>ld</command> 传递 "
  433. "<parameter>--verbose</parameter> 参数,可以知道哪些文件被链接。例如,"
  434. "<userinput>gcc dummy.c -Wl,--verbose 2&gt;&amp;1 | grep succeeded</"
  435. "userinput> 将显示所有在链接过程中被成功打开的文件。"
  436. #. type: Content of: <sect1><sect2><para>
  437. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:268
  438. msgid ""
  439. "The next package installed is GCC. An example of what can be seen during its "
  440. "run of <command>configure</command> is:"
  441. msgstr ""
  442. "下一步安装 GCC。在执行它的 <command>configure</command> 脚本时,您会看到类似"
  443. "下面这样的输出:"
  444. #. type: Content of: <sect1><sect2><screen>
  445. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:271
  446. #, no-wrap
  447. msgid ""
  448. "<computeroutput>checking what assembler to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/as\n"
  449. "checking what linker to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/ld</computeroutput>"
  450. msgstr ""
  451. "<computeroutput>checking what assembler to use... /tools/i686-lfs-linux-gnu/bin/as\n"
  452. "checking what linker to use... /mnt/lfs/tools/i686-lfs-linux-gnu/bin/ld</computeroutput>"
  453. #. type: Content of: <sect1><sect2><para>
  454. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:274
  455. msgid ""
  456. "This is important for the reasons mentioned above. It also demonstrates that "
  457. "GCC's configure script does not search the PATH directories to find which "
  458. "tools to use. However, during the actual operation of <command>gcc</command> "
  459. "itself, the same search paths are not necessarily used. To find out which "
  460. "standard linker <command>gcc</command> will use, run: <command>$LFS_TGT-gcc -"
  461. "print-prog-name=ld</command>."
  462. msgstr ""
  463. "基于我们上面论述的原因,这些输出非常重要。这说明 GCC 的配置脚本没有在 PATH 变"
  464. "量指定的目录中搜索工具。然而,在 <command>gcc</command> 的实际运行中,未必会"
  465. "使用同样的搜索路径。为了查询 <command>gcc</command> 会使用哪个链接器,需要执"
  466. "行以下命令:<userinput>$LFS_TGT-gcc -print-prog-name=ld</userinput>。"
  467. #. type: Content of: <sect1><sect2><para>
  468. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:281
  469. msgid ""
  470. "Detailed information can be obtained from <command>gcc</command> by passing "
  471. "it the <parameter>-v</parameter> command line option while compiling a dummy "
  472. "program. For example, <command>gcc -v dummy.c</command> will show detailed "
  473. "information about the preprocessor, compilation, and assembly stages, "
  474. "including <command>gcc</command>'s included search paths and their order."
  475. msgstr ""
  476. "通过向 <command>gcc</command> 传递 <parameter>-v</parameter> 参数,可以知道在"
  477. "编译样品程序时发生的细节。例如,<userinput>gcc -v dummy.c</userinput> 会输出"
  478. "预处理、编译和汇编阶段中的详细信息,包括 <command>gcc</command> 的包含文件搜"
  479. "索路径和顺序。"
  480. #. type: Content of: <sect1><sect2><para>
  481. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:288
  482. msgid ""
  483. "Next installed are sanitized Linux API headers. These allow the standard C "
  484. "library (Glibc) to interface with features that the Linux kernel will "
  485. "provide."
  486. msgstr ""
  487. "下一步安装“净化的” (sanitized) Linux API 头文件。这允许 C 标准库 (Glibc) 与 "
  488. "Linux 内核提供的各种特性交互。"
  489. #. type: Content of: <sect1><sect2><para>
  490. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:292
  491. msgid ""
  492. "The next package installed is Glibc. The most important considerations for "
  493. "building Glibc are the compiler, binary tools, and kernel headers. The "
  494. "compiler is generally not an issue since Glibc will always use the compiler "
  495. "relating to the <parameter>--host</parameter> parameter passed to its "
  496. "configure script; e.g. in our case, the compiler will be <command>$LFS_TGT-"
  497. "gcc</command>. The binary tools and kernel headers can be a bit more "
  498. "complicated. Therefore, take no risks and use the available configure "
  499. "switches to enforce the correct selections. After the run of "
  500. "<command>configure</command>, check the contents of the <filename>config."
  501. "make</filename> file in the <filename class=\"directory\">build</filename> "
  502. "directory for all important details. Note the use of <parameter>CC="
  503. "\"$LFS_TGT-gcc\"</parameter> (with <envar>$LFS_TGT</envar> expanded) to "
  504. "control which binary tools are used and the use of the <parameter>-nostdinc</"
  505. "parameter> and <parameter>-isystem</parameter> flags to control the "
  506. "compiler's include search path. These items highlight an important aspect of "
  507. "the Glibc package&mdash;it is very self-sufficient in terms of its build "
  508. "machinery and generally does not rely on toolchain defaults."
  509. msgstr ""
  510. "下一步安装 Glibc。在构建 Glibc 时需要着重考虑是编译器,二进制工具,以及内核头"
  511. "文件。编译器一般不成问题,Glibc 总是使用传递给配置脚本的 <parameter>--host</"
  512. "parameter> 参数相关的编译器。例如,在我们的例子中,使用的编译器是 <command>"
  513. "$LFS_TGT-gcc</command>。但二进制工具和内核头文件的问题比较复杂。安全起见,我"
  514. "们使用配置脚本提供的开关,保证正确的选择。在 <command>configure</command> 脚"
  515. "本运行完成后,可以检查 <filename>build</filename> 目录中的 <filename>config."
  516. "make</filename> 文件,了解全部重要的细节。注意参数 <parameter>CC=\"$LFS_TGT-"
  517. "gcc\"</parameter> (其中 <envar>$LFS_TGT</envar> 会被展开) 控制构建系统使用正"
  518. "确的二进制工具,而参数 <parameter>-nostdinc</parameter> 和 <parameter>-"
  519. "isystem</parameter> 控制编译器的包含文件搜索路径。这些事项凸显了 Glibc 软件包"
  520. "的一个重要性质 —— 它的构建机制是相当自给自足的,通常不依赖于工具链默认值。"
  521. #. type: Content of: <sect1><sect2><para>
  522. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:311
  523. msgid ""
  524. "As said above, the standard C++ library is compiled next, followed in <xref "
  525. "linkend=\"chapter-temporary-tools\"/> by all the programs that need "
  526. "themselves to be built. The install step of all those packages uses the "
  527. "<envar>DESTDIR</envar> variable to have the programs land into the LFS "
  528. "filesystem."
  529. msgstr ""
  530. "正如前文所述,接下来构建 C++ 标准库,然后是<xref linkend=\"chapter-temporary-tools\"/>中那些需要自身才"
  531. "能构建的程序后。在安装这些软件包时使用 <envar>DESTDIR</"
  532. "envar> 变量,将它安装到 LFS 文件系统中。"
  533. #. type: Content of: <sect1><sect2><para>
  534. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:317
  535. msgid ""
  536. "At the end of <xref linkend=\"chapter-temporary-tools\"/> the native lfs "
  537. "compiler is installed. First binutils-pass2 is built, with the same "
  538. "<envar>DESTDIR</envar> install as the other programs, then the second pass "
  539. "of GCC is constructed, omitting libstdc++ and other non-important "
  540. "libraries. Due to some weird logic in GCC's configure script, "
  541. "<envar>CC_FOR_TARGET</envar> ends up as <command>cc</command> when the host "
  542. "is the same as the target, but is different from the build system. This is "
  543. "why <parameter>CC_FOR_TARGET=$LFS_TGT-gcc</parameter> is put explicitely "
  544. "into the configure options."
  545. msgstr ""
  546. "在<xref linkend=\"chapter-temporary-tools\"/>一节的末尾,构建 lfs 本地编译"
  547. "器。首先使用和其他程序相同的 <envar>DESTDIR</envar> 第二次构建 binutils,然后"
  548. "第二次构建 GCC,构建时忽略 libstdc++ 和其他不重要的库。由于 GCC 配置脚本的一"
  549. "些奇怪逻辑,<envar>CC_FOR_TARGET</envar> 变量在 host 系统和 target 相同,但"
  550. "与 build 不同时,被设定为 <command>cc</command>。因此我们必须显式地在配置选项"
  551. "中指定 <parameter>CC_FOR_TARGET=$LFS_TGT-gcc</parameter>。"
  552. #. type: Content of: <sect1><sect2><para>
  553. #: /home/xry111/svn-repos/LFS-BOOK/part3intro/toolchaintechnotes.xml:328
  554. msgid ""
  555. "Upon entering the chroot environment in <xref linkend=\"chapter-chroot-"
  556. "temporary-tools\"/>, the first task is to install libstdc++. Then temporary "
  557. "installations of programs needed for the proper operation of the toolchain "
  558. "are performed. Programs needed for testing other programs are also built. "
  559. "From this point onwards, the core toolchain is self-contained and self-"
  560. "hosted. In <xref linkend=\"chapter-building-system\"/>, final versions of "
  561. "all the packages needed for a fully functional system are built, tested and "
  562. "installed."
  563. msgstr ""
  564. "在<xref linkend=\"chapter-chroot-temporary-tools\"/>中,进入 chroot 环境后,"
  565. "首先安装 libstdc++。之后临时性地安装工具链的正常工作所必须的程序。还要构建测"
  566. "试其他程序时必须的程序。此后,核心工具链成为自包含的本地工具链。在<xref "
  567. "linkend=\"chapter-building-system\"/>中,构建、测试并最后一次安装所有软件包,"
  568. "它们组成功能完整的系统。"