Skip to content

Commit 55b8d0a

Browse files
Yanteng SiJonathan Corbet
authored andcommitted
docs/zh_CN/rust: Update the translation of quick-start to 6.9-rc4
Update to commit 711cbfc ("docs: rust: Clarify that 'rustup override' applies to build directory") commit 7583ce6 ("docs: rust: remove `CC=clang` mentions") commit 2285eb2 ("docs: rust: clarify what 'rustup override' does") commit 8cb4012 ("docs: rust: update instructions for obtaining 'core' source") commit b603c6c ("docs: rust: add command line to rust-analyzer section") commit 08ab786 ("rust: bindgen: upgrade to 0.65.1") commit eae9017 ("docs: rust: add paragraph about finding a suitable `libclang`") commit 6883b29 ("docs: rust: point directly to the standalone installers") Signed-off-by: Yanteng Si <[email protected]> Reviewed-by: Dongliang Mu <[email protected]> Signed-off-by: Jonathan Corbet <[email protected]> Link: https://lore.kernel.org/r/aff560c262f255e873c07cc66891cf8140ad433d.1714113680.git.siyanteng@loongson.cn
1 parent 9148195 commit 55b8d0a

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

Documentation/translations/zh_CN/rust/quick-start.rst

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,18 @@ rustc
3737
需要一个特定版本的Rust编译器。较新的版本可能会也可能不会工作,因为就目前而言,内核依赖
3838
于一些不稳定的Rust特性。
3939

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

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

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

46-
https://www.rust-lang.org
47+
请注意覆盖应用当前的工作目录(和它的子目录)。
48+
49+
如果你使用 ``rustup``, 可以从下面的链接拉取一个单独的安装程序:
50+
51+
https://forge.rust-lang.org/infra/other-installation-methods.html#standalone
4752

4853

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

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

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

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

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

6976

7077
libclang
7178
********
7279

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

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

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

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

97-
cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen
104+
cargo install --locked --version $(scripts/min-tool-version.sh bindgen) bindgen-cli
105+
106+
``bindgen`` 需要找到合适的 ``libclang`` 才能工作。如果没有找到(或者找到的
107+
``libclang`` 与应该使用的 ``libclang`` 不同),则可以使用 ``clang-sys``
108+
理解的环境变量(Rust绑定创建的 ``bindgen`` 用来访问 ``libclang``):
109+
110+
111+
* ``LLVM_CONFIG_PATH`` 可以指向一个 ``llvm-config`` 可执行文件。
112+
113+
* 或者 ``LIBCLANG_PATH`` 可以指向 ``libclang`` 共享库或包含它的目录。
114+
115+
* 或者 ``CLANG_PATH`` 可以指向 ``clang`` 可执行文件。
116+
117+
详情请参阅 ``clang-sys`` 的文档:
98118

99119

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

165185
``rust-analyzer`` 需要一个配置文件, ``rust-project.json``, 它可以由 ``rust-analyzer``
166-
Make 目标生成。
186+
Make 目标生成::
187+
188+
make LLVM=1 rust-analyzer
167189

168190

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

190212
make LLVM=1
191213

192-
对于不支持完整LLVM工具链的架构,使用::
193-
194-
make CC=clang
195-
196214
使用GCC对某些配置也是可行的,但目前它是非常试验性的。
197215

198216

0 commit comments

Comments
 (0)