Skip to content

Commit 74ed6f1

Browse files
author
刘丰源
committed
add rust install help
1 parent c29f9b2 commit 74ed6f1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5393
-574
lines changed

SUMMARY.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,6 @@
7575
- [6. 用户进程(+ 虚拟内存管理 + 线程管理)](./exercise/part6.md)
7676
- [7. 同步互斥(TODO)](./exercise/part7.md)
7777
- [8. 文件系统](./exercise/part8.md)
78-
- [附录]
79-
- [内联汇编](appendix/inline-asm.md)
78+
- [附录](./appendix/introduction.md)
79+
- [内联汇编](appendix/inline_asm.md)
80+
- [安装 rust](appendix/install_rust.md)

appendix/install_rust.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 安装 rust
2+
3+
## 安装 rustup
4+
5+
`rustup` 是 rust 的工具链管理器,通过它可以下载 rust 工具链(类似 `apt-get install gcc` 的感觉)。如果官方途径下载遇到了困难,可以尝试以下方法:
6+
7+
```bash
8+
export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
9+
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
10+
curl https://sh.rustup.rs -sSf | sh
11+
```
12+
13+
如果还是失败了,手动下载安装脚本:在浏览器里输入 `https://sh.rustup.rs` ,将下载的脚本中 `RUSTUP_UPDATE_ROOT:-https://static.rust-lang.org/rustup` 改为 `RUSTUP_UPDATE_ROOT:-https://mirrors.ustc.edu.cn/rust-static/rustup` (科大源),运行脚本即可。
14+
15+
## rustup 换源
16+
17+
参考:https://mirrors.tuna.tsinghua.edu.cn/help/rustup/
18+
19+
## crate.io 换源
20+
21+
新建文件 `~/.cargo/config` ,在里面输入如下内容:
22+
23+
```
24+
[source.crates-io]
25+
registry = "https://github.com/rust-lang/crates.io-index"
26+
replace-with = 'ustc'
27+
[source.ustc]
28+
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
29+
```

appendix/introduction.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# 附录

chapter1/part1.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
$ curl https://sh.rustup.rs -sSf | sh
99
```
1010

11+
> 如果安装 rust 的过程中出现了困难,可以阅读 [附录:安装 rust](../appendix/install_rust.md)
12+
1113
Rust 包含:stable、beta、nightly 三个版本。默认情况下我们安装的是 stable 稳定版。由于在编写操作系统时需要使用 Rust 的一些不稳定的实验功能,因此我们使用 nightly 每日构建版。
1214

1315
但是,由于官方不保证 nightly 版本的 ABI 稳定性,也就意味着今天写的代码用未来的 nightly 可能无法编译通过,因此一般在使用 nightly 时应该锁定一个日期。
1416

15-
我们在工作目录下创建一个名为 `rust-toolchain` 的文件,并在其中写入所需的工具链版本:
17+
我们在工作目录下创建一个名为 `rust-toolchain` 的文件(无后缀),并在其中写入所需的工具链版本:
1618

1719
```
1820
nightly-2020-01-27

0 commit comments

Comments
 (0)