|
3 | 3 | ## Nightly toolchain |
4 | 4 |
|
5 | 5 | Rust's nightly toolchain is currently required because uefi-rs uses some |
6 | | -unstable features. The [`build-std`] feature we use to build the |
7 | | -standard libraries is also unstable. |
| 6 | +unstable features. |
8 | 7 |
|
9 | 8 | The easiest way to set this up is using a [rustup toolchain file]. In |
10 | 9 | the root of your repository, add `rust-toolchain.toml`: |
11 | 10 |
|
12 | 11 | ```toml |
13 | 12 | [toolchain] |
14 | 13 | channel = "nightly" |
15 | | -components = ["rust-src"] |
| 14 | +targets = ["x86_64-unknown-uefi"] |
16 | 15 | ``` |
17 | 16 |
|
| 17 | +Here we have specified the `x86_64-unknown-uefi` target; there are also |
| 18 | +`i686-unknown-uefi` and `aarch64-unknown-uefi` targets available. |
| 19 | + |
18 | 20 | Note that nightly releases can sometimes break, so you might opt to pin |
19 | | -to a specific release. For example, `channel = "nightly-2022-09-01"`. |
| 21 | +to a specific release. For example, `channel = "nightly-2022-11-10"`. |
20 | 22 |
|
21 | 23 | ## Build the application |
22 | 24 |
|
23 | 25 | Run this command to build the application: |
24 | 26 |
|
25 | 27 | ```sh |
26 | | -cargo build --target x86_64-unknown-uefi \ |
27 | | - -Zbuild-std=core,alloc |
| 28 | +cargo build --target x86_64-unknown-uefi |
28 | 29 | ``` |
29 | 30 |
|
30 | 31 | This will produce an x86-64 executable: |
31 | 32 | `target/x86_64-unknown-uefi/debug/my-uefi-app.efi`. |
32 | 33 |
|
33 | | -## Simplifying the build command |
34 | | - |
35 | | -The above build command is verbose and not easy to remember. With a bit |
36 | | -of configuration we can simplify it a lot. |
37 | | - |
38 | | -Create a `.cargo` directory in the root of the project: |
39 | | - |
40 | | -```sh |
41 | | -mkdir .cargo |
42 | | -``` |
43 | | - |
44 | | -Create `.cargo/config.toml` with these contents: |
45 | | - |
46 | | -```toml |
47 | | -[build] |
48 | | -target = "x86_64-unknown-uefi" |
49 | | - |
50 | | -[unstable] |
51 | | -build-std = ["core", "alloc"] |
52 | | -``` |
53 | | - |
54 | | -Now you can build much more simply: |
55 | | - |
56 | | -```sh |
57 | | -cargo build |
58 | | -``` |
59 | | - |
60 | | -[`build-std`]: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#build-std |
61 | | -[`rust-toolchain.toml`]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file |
62 | | -[rustup toolchain file]: https://rust-lang.github.io/rustup/concepts/toolchains.html |
| 34 | +[rustup toolchain file]: https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file |
0 commit comments