Commit 55b8d0a3 authored by Yanteng Si's avatar Yanteng Si Committed by Jonathan Corbet
Browse files

docs/zh_CN/rust: Update the translation of quick-start to 6.9-rc4



Update to commit 711cbfc7 ("docs: rust: Clarify that 'rustup
override' applies to build directory")
commit 7583ce66 ("docs: rust: remove `CC=clang` mentions")
commit 2285eb2f ("docs: rust: clarify what 'rustup override' does")
commit 8cb40124 ("docs: rust: update instructions for obtaining
'core' source")
commit b603c6cc ("docs: rust: add command line to rust-analyzer
section")
commit 08ab7865 ("rust: bindgen: upgrade to 0.65.1")
commit eae90172 ("docs: rust: add paragraph about finding a
suitable `libclang`")
commit 6883b29c ("docs: rust: point directly to the standalone
installers")

Signed-off-by: default avatarYanteng Si <siyanteng@loongson.cn>
Reviewed-by: default avatarDongliang Mu <dzm91@hust.edu.cn>
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/aff560c262f255e873c07cc66891cf8140ad433d.1714113680.git.siyanteng@loongson.cn
parent 91481952
Loading
Loading
Loading
Loading
+34 −16
Original line number Diff line number Diff line
@@ -37,13 +37,18 @@ rustc
需要一个特定版本的Rust编译器。较新的版本可能会也可能不会工作,因为就目前而言,内核依赖
于一些不稳定的Rust特性。

如果使用的是 ``rustup`` ,请进入检出的源代码目录并运行::
如果使用的是 ``rustup`` ,请进入内核编译目录(或者用 ``--path=<build-dir>`` 参数
来 ``设置`` sub-command)并运行::

	rustup override set $(scripts/min-tool-version.sh rustc)

或者从以下网址获取一个独立的安装程序或安装 ``rustup`` :
+这将配置你的工作目录使用正确版本的 ``rustc``,而不影响你的默认工具链。

	https://www.rust-lang.org
请注意覆盖应用当前的工作目录(和它的子目录)。

如果你使用 ``rustup``, 可以从下面的链接拉取一个单独的安装程序:

	https://forge.rust-lang.org/infra/other-installation-methods.html#standalone


Rust标准库源代码
@@ -57,21 +62,23 @@ Rust标准库的源代码是必需的,因为构建系统会交叉编译 ``core

这些组件是按工具链安装的,因此以后升级Rust编译器版本需要重新添加组件。

否则,如果使用独立的安装程序,可以将Rust仓库克隆到工具链的安装文件夹中::
否则,如果使用独立的安装程序,可以将Rust源码树下载到安装工具链的文件夹中::

	git clone --recurse-submodules \
		--branch $(scripts/min-tool-version.sh rustc) \
		https://github.com/rust-lang/rust \
		$(rustc --print sysroot)/lib/rustlib/src/rust
       curl -L "https://static.rust-lang.org/dist/rust-src-$(scripts/min-tool-version.sh rustc).tar.gz" |
               tar -xzf - -C "$(rustc --print sysroot)/lib" \
               "rust-src-$(scripts/min-tool-version.sh rustc)/rust-src/lib/" \
               --strip-components=3

在这种情况下,以后升级Rust编译器版本需要手动更新这个克隆的仓库。
在这种情况下,以后升级Rust编译器版本需要手动更新这个源代码树(这可以通过移除
``$(rustc --print sysroot)/lib/rustlib/src/rust`` ,然后重新执行上
面的命令做到)。


libclang
********

``bindgen`` 使用 ``libclang`` (LLVM的一部分)来理解内核中的C代码,这意味着需要安
装LLVM;同在开启 ``CC=clang`` 或 ``LLVM=1`` 时编译内核一样。
装LLVM;同在开启``LLVM=1`` 时编译内核一样。

Linux发行版中可能会有合适的包,所以最好先检查一下。

@@ -94,7 +101,20 @@ bindgen

通过以下方式安装它(注意,这将从源码下载并构建该工具)::

	cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen
	cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen-cli

``bindgen`` 需要找到合适的 ``libclang`` 才能工作。如果没有找到(或者找到的
``libclang`` 与应该使用的 ``libclang`` 不同),则可以使用 ``clang-sys``
理解的环境变量(Rust绑定创建的 ``bindgen`` 用来访问 ``libclang``):


* ``LLVM_CONFIG_PATH`` 可以指向一个 ``llvm-config`` 可执行文件。

* 或者 ``LIBCLANG_PATH`` 可以指向 ``libclang`` 共享库或包含它的目录。

* 或者 ``CLANG_PATH`` 可以指向 ``clang`` 可执行文件。

详情请参阅 ``clang-sys`` 的文档:


开发依赖
@@ -163,7 +183,9 @@ rust-analyzer
一起使用,以实现语法高亮、补全、转到定义和其他功能。

``rust-analyzer`` 需要一个配置文件, ``rust-project.json``, 它可以由 ``rust-analyzer``
Make 目标生成。
Make 目标生成::

       make LLVM=1 rust-analyzer


配置
@@ -189,10 +211,6 @@ Rust支持(CONFIG_RUST)需要在 ``General setup`` 菜单中启用。在其

	make LLVM=1

对于不支持完整LLVM工具链的架构,使用::

	make CC=clang

使用GCC对某些配置也是可行的,但目前它是非常试验性的。