Skip to content

Commit fb52014

Browse files
Add rust-toolchain.toml
Add a `rust-toolchain.toml` file that specifies the channel and components needed to build uefi-rs. See https://rust-lang.github.io/rustup/overrides.html#the-toolchain-file for documentation of the `rust-toolchain.toml` format. Remove the `--toolchain` option from `xtask`, as using this file is a simpler alternative. Also remove the instructions for installing the nightly toolchain from the readme, as `rustup` will do this automatically now. The `toolchain` action previously used in the CI is unmaintained and doesn't understand `rust-toolchain.toml` (it does understand the older `rust-toolchain` file, but that doesn't allow for including required components). Since the runners come with rustup already installed, we don't actually need a complex action here anyway, so just remove those sections entirely. Note that this change will also cause `xtask` itself to be built with nightly. That should generally be fine, we only had it using stable because of rust-osdev#397, and in the future we can easily temporarily pin to a non-current nightly if a bug occurs with an `xtask` dependency again. Fixes rust-osdev#498
1 parent 55e6896 commit fb52014

File tree

6 files changed

+17
-154
lines changed

6 files changed

+17
-154
lines changed

.github/workflows/rust.yml

-95
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,6 @@ jobs:
2828
sudo apt-get update
2929
sudo apt-get install qemu-system-arm qemu-efi-aarch64 -y
3030
31-
- name: Install stable
32-
uses: actions-rs/toolchain@v1
33-
with:
34-
toolchain: stable
35-
36-
- name: Install latest nightly
37-
uses: actions-rs/toolchain@v1
38-
with:
39-
toolchain: nightly
40-
components: rust-src
41-
# TODO: cache Rust binaries
42-
4331
- name: Build
4432
run: cargo xtask build --target aarch64
4533

@@ -59,18 +47,6 @@ jobs:
5947
sudo apt-get update
6048
sudo apt-get install qemu-system-x86 ovmf -y
6149
62-
- name: Install stable
63-
uses: actions-rs/toolchain@v1
64-
with:
65-
toolchain: stable
66-
67-
- name: Install latest nightly
68-
uses: actions-rs/toolchain@v1
69-
with:
70-
toolchain: nightly
71-
components: rust-src
72-
# TODO: cache Rust binaries
73-
7450
- name: Build
7551
run: cargo xtask build --target x86_64
7652

@@ -106,18 +82,6 @@ jobs:
10682
curl -o OVMF32_CODE.fd https://raw.githubusercontent.com/retrage/edk2-nightly/${EDK2_NIGHTLY_COMMIT}/bin/RELEASEIa32_OVMF_CODE.fd
10783
curl -o OVMF32_VARS.fd https://raw.githubusercontent.com/retrage/edk2-nightly/${EDK2_NIGHTLY_COMMIT}/bin/RELEASEIa32_OVMF_VARS.fd
10884
109-
- name: Install stable
110-
uses: actions-rs/toolchain@v1
111-
with:
112-
toolchain: stable
113-
114-
- name: Install latest nightly
115-
uses: actions-rs/toolchain@v1
116-
with:
117-
toolchain: nightly
118-
components: rust-src
119-
# TODO: cache Rust binaries
120-
12185
- name: Build
12286
run: cargo xtask build --target ia32
12387

@@ -132,18 +96,6 @@ jobs:
13296
- name: Checkout sources
13397
uses: actions/checkout@v2
13498

135-
- name: Install stable
136-
uses: actions-rs/toolchain@v1
137-
with:
138-
toolchain: stable
139-
140-
- name: Install latest nightly
141-
uses: actions-rs/toolchain@v1
142-
with:
143-
profile: minimal
144-
toolchain: nightly
145-
components: rust-src
146-
14799
- name: Run cargo test
148100
run: cargo xtask test
149101

@@ -154,18 +106,6 @@ jobs:
154106
- name: Checkout sources
155107
uses: actions/checkout@v2
156108

157-
- name: Install stable
158-
uses: actions-rs/toolchain@v1
159-
with:
160-
toolchain: stable
161-
162-
- name: Install latest nightly
163-
uses: actions-rs/toolchain@v1
164-
with:
165-
profile: minimal
166-
toolchain: nightly
167-
components: rustfmt, clippy, rust-src
168-
169109
- name: Run cargo fmt
170110
uses: actions-rs/cargo@v1
171111
with:
@@ -185,18 +125,6 @@ jobs:
185125
- name: Checkout sources
186126
uses: actions/checkout@v2
187127

188-
- name: Install stable
189-
uses: actions-rs/toolchain@v1
190-
with:
191-
toolchain: stable
192-
193-
- name: Install latest nightly toolchain that includes Miri
194-
uses: actions-rs/toolchain@v1
195-
with:
196-
profile: minimal
197-
toolchain: nightly
198-
components: miri
199-
200128
- name: Run miri
201129
run: cargo xtask miri
202130

@@ -214,17 +142,6 @@ jobs:
214142
- name: Checkout sources
215143
uses: actions/checkout@v2
216144

217-
- name: Install stable
218-
uses: actions-rs/toolchain@v1
219-
with:
220-
toolchain: stable
221-
222-
- name: Install latest nightly
223-
uses: actions-rs/toolchain@v1
224-
with:
225-
toolchain: nightly
226-
components: rust-src
227-
228145
- name: Build
229146
run: cargo xtask test-latest-release
230147

@@ -235,17 +152,5 @@ jobs:
235152
- name: Checkout sources
236153
uses: actions/checkout@v2
237154

238-
- name: Install stable
239-
uses: actions-rs/toolchain@v1
240-
with:
241-
toolchain: stable
242-
243-
- name: Install latest nightly
244-
uses: actions-rs/toolchain@v1
245-
with:
246-
profile: minimal
247-
toolchain: nightly
248-
components: rust-src
249-
250155
- name: Build
251156
run: cargo xtask build

README.md

-6
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,6 @@ the [UEFI specification][spec] for detailed information.
6363

6464
## Building and testing uefi-rs
6565

66-
Install the `nightly` version of Rust and the `rust-src` component:
67-
```
68-
rustup toolchain install nightly
69-
rustup component add --toolchain nightly rust-src
70-
```
71-
7266
Use the `cargo xtask` command to build and test the crate.
7367

7468
Available commands:

rust-toolchain.toml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[toolchain]
2+
# Nightly is required due to use of unstable features.
3+
channel = "nightly"
4+
components = [
5+
# Needed for `cargo xtask miri`.
6+
"miri",
7+
# Needed for `-Zbuild-std`.
8+
"rust-src",
9+
10+
"rustfmt",
11+
]

xtask/src/cargo.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ pub fn fix_nested_cargo_env(cmd: &mut Command) {
118118
pub struct Cargo {
119119
pub action: CargoAction,
120120
pub features: Vec<Feature>,
121-
pub toolchain: Option<String>,
122121
pub packages: Vec<Package>,
123122
pub release: bool,
124123
pub target: Option<UefiArch>,
@@ -131,10 +130,6 @@ impl Cargo {
131130

132131
fix_nested_cargo_env(&mut cmd);
133132

134-
if let Some(toolchain) = &self.toolchain {
135-
cmd.arg(&format!("+{}", toolchain));
136-
}
137-
138133
let action;
139134
let mut sub_action = None;
140135
let mut extra_args: Vec<&str> = Vec::new();
@@ -239,15 +234,14 @@ mod tests {
239234
let cargo = Cargo {
240235
action: CargoAction::Doc { open: true },
241236
features: vec![Feature::Alloc],
242-
toolchain: Some("nightly".into()),
243237
packages: vec![Package::Uefi, Package::Xtask],
244238
release: false,
245239
target: None,
246240
warnings_as_errors: true,
247241
};
248242
assert_eq!(
249243
command_to_string(&cargo.command().unwrap()),
250-
"RUSTDOCFLAGS=-Dwarnings cargo +nightly doc --package uefi --package xtask --features alloc --open"
244+
"RUSTDOCFLAGS=-Dwarnings cargo doc --package uefi --package xtask --features alloc --open"
251245
);
252246
}
253247
}

xtask/src/main.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ mod util;
1111
use anyhow::Result;
1212
use cargo::{fix_nested_cargo_env, Cargo, CargoAction, Feature, Package};
1313
use clap::Parser;
14-
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, MiriOpt, Opt, QemuOpt};
14+
use opt::{Action, BuildOpt, ClippyOpt, DocOpt, Opt, QemuOpt};
1515
use std::process::Command;
1616
use tempfile::TempDir;
1717
use util::{command_to_string, run_cmd};
1818

19-
const NIGHTLY: &str = "nightly";
20-
2119
fn build(opt: &BuildOpt) -> Result<()> {
2220
let cargo = Cargo {
2321
action: CargoAction::Build,
2422
features: Feature::more_code(),
25-
toolchain: opt.toolchain.or(NIGHTLY),
2623
packages: Package::all_except_xtask(),
2724
release: opt.build_mode.release,
2825
target: Some(*opt.target),
@@ -36,7 +33,6 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
3633
let cargo = Cargo {
3734
action: CargoAction::Clippy,
3835
features: Feature::more_code(),
39-
toolchain: opt.toolchain.or(NIGHTLY),
4036
packages: Package::all_except_xtask(),
4137
release: false,
4238
target: Some(*opt.target),
@@ -48,7 +44,6 @@ fn clippy(opt: &ClippyOpt) -> Result<()> {
4844
let cargo = Cargo {
4945
action: CargoAction::Clippy,
5046
features: Vec::new(),
51-
toolchain: None,
5247
packages: vec![Package::Xtask],
5348
release: false,
5449
target: None,
@@ -62,7 +57,6 @@ fn doc(opt: &DocOpt) -> Result<()> {
6257
let cargo = Cargo {
6358
action: CargoAction::Doc { open: opt.open },
6459
features: Feature::more_code(),
65-
toolchain: opt.toolchain.or(NIGHTLY),
6660
packages: Package::published(),
6761
release: false,
6862
target: None,
@@ -72,11 +66,10 @@ fn doc(opt: &DocOpt) -> Result<()> {
7266
}
7367

7468
/// Run unit tests and doctests under Miri.
75-
fn run_miri(opt: &MiriOpt) -> Result<()> {
69+
fn run_miri() -> Result<()> {
7670
let cargo = Cargo {
7771
action: CargoAction::Miri,
7872
features: [Feature::Exts].into(),
79-
toolchain: opt.toolchain.or(NIGHTLY),
8073
packages: [Package::Uefi].into(),
8174
release: false,
8275
target: None,
@@ -100,7 +93,6 @@ fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
10093
let cargo = Cargo {
10194
action: CargoAction::Build,
10295
features,
103-
toolchain: opt.toolchain.or(NIGHTLY),
10496
packages: vec![Package::UefiTestRunner],
10597
release: opt.build_mode.release,
10698
target: Some(*opt.target),
@@ -119,7 +111,6 @@ fn run_host_tests() -> Result<()> {
119111
let cargo = Cargo {
120112
action: CargoAction::Test,
121113
features: Vec::new(),
122-
toolchain: None,
123114
packages: vec![Package::Xtask],
124115
release: false,
125116
target: None,
@@ -131,7 +122,6 @@ fn run_host_tests() -> Result<()> {
131122
let cargo = Cargo {
132123
action: CargoAction::Test,
133124
features: vec![Feature::Exts],
134-
toolchain: Some(NIGHTLY.into()),
135125
// Don't test uefi-services (or the packages that depend on it)
136126
// as it has lang items that conflict with `std`.
137127
packages: vec![Package::Uefi, Package::UefiMacros],
@@ -173,7 +163,7 @@ fn test_latest_release() -> Result<()> {
173163
let mut build_cmd = Command::new("cargo");
174164
fix_nested_cargo_env(&mut build_cmd);
175165
build_cmd
176-
.args(&["+nightly", "build", "--target", "x86_64-unknown-uefi"])
166+
.args(&["build", "--target", "x86_64-unknown-uefi"])
177167
.current_dir(tmp_dir.join("template"));
178168

179169
// Check that the command is indeed in BUILDING.md, then verify the
@@ -190,7 +180,7 @@ fn main() -> Result<()> {
190180
Action::Build(build_opt) => build(build_opt),
191181
Action::Clippy(clippy_opt) => clippy(clippy_opt),
192182
Action::Doc(doc_opt) => doc(doc_opt),
193-
Action::Miri(miri_opt) => run_miri(miri_opt),
183+
Action::Miri(_) => run_miri(),
194184
Action::Run(qemu_opt) => run_vm_tests(qemu_opt),
195185
Action::Test(_) => run_host_tests(),
196186
Action::TestLatestRelease(_) => test_latest_release(),

xtask/src/opt.rs

+1-32
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,6 @@ impl Deref for TargetOpt {
2121
}
2222
}
2323

24-
#[derive(Debug, Parser)]
25-
pub struct ToolchainOpt {
26-
/// Rust toolchain to use, e.g. "nightly-2022-02-24".
27-
#[clap(long, action)]
28-
toolchain: Option<String>,
29-
}
30-
31-
impl ToolchainOpt {
32-
/// Get the toolchain arg if set, otherwise use `default_toolchain`.
33-
pub fn or(&self, default_toolchain: &str) -> Option<String> {
34-
self.toolchain
35-
.clone()
36-
.or_else(|| Some(default_toolchain.to_string()))
37-
}
38-
}
39-
4024
#[derive(Debug, Parser)]
4125
pub struct BuildModeOpt {
4226
/// Build in release mode.
@@ -75,9 +59,6 @@ pub struct BuildOpt {
7559
#[clap(flatten)]
7660
pub target: TargetOpt,
7761

78-
#[clap(flatten)]
79-
pub toolchain: ToolchainOpt,
80-
8162
#[clap(flatten)]
8263
pub build_mode: BuildModeOpt,
8364
}
@@ -88,19 +69,13 @@ pub struct ClippyOpt {
8869
#[clap(flatten)]
8970
pub target: TargetOpt,
9071

91-
#[clap(flatten)]
92-
pub toolchain: ToolchainOpt,
93-
9472
#[clap(flatten)]
9573
pub warning: WarningOpt,
9674
}
9775

9876
/// Build the docs for the uefi packages.
9977
#[derive(Debug, Parser)]
10078
pub struct DocOpt {
101-
#[clap(flatten)]
102-
pub toolchain: ToolchainOpt,
103-
10479
/// Open the docs in a browser.
10580
#[clap(long, action)]
10681
pub open: bool,
@@ -111,20 +86,14 @@ pub struct DocOpt {
11186

11287
/// Run unit tests and doctests under Miri.
11388
#[derive(Debug, Parser)]
114-
pub struct MiriOpt {
115-
#[clap(flatten)]
116-
pub toolchain: ToolchainOpt,
117-
}
89+
pub struct MiriOpt {}
11890

11991
/// Build uefi-test-runner and run it in QEMU.
12092
#[derive(Debug, Parser)]
12193
pub struct QemuOpt {
12294
#[clap(flatten)]
12395
pub target: TargetOpt,
12496

125-
#[clap(flatten)]
126-
pub toolchain: ToolchainOpt,
127-
12897
#[clap(flatten)]
12998
pub build_mode: BuildModeOpt,
13099

0 commit comments

Comments
 (0)