Skip to content

Commit a0c5468

Browse files
committed
Migrate to x86_64-unknown-none
1 parent e2ee706 commit a0c5468

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ ENV RUSTUP_HOME=/usr/local/rustup \
66
PATH=/usr/local/cargo/bin:$PATH \
77
# Manually sync this with rust-toolchain.toml!
88
RUST_VERSION=nightly-2022-04-24 \
9-
RUST_COMPONENTS="clippy llvm-tools-preview rustfmt rust-src"
9+
RUST_COMPONENTS="clippy llvm-tools-preview rustfmt rust-src" \
10+
RUST_TARGETS="x86_64-unknown-none"
1011

1112
RUN set -eux; \
1213
dpkgArch="$(dpkg --print-architecture)"; \
@@ -26,6 +27,7 @@ RUN set -eux; \
2627
--default-toolchain $RUST_VERSION \
2728
--default-host ${rustArch} \
2829
--component $RUST_COMPONENTS \
30+
--target $RUST_TARGETS \
2931
; \
3032
rm rustup-init; \
3133
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \

rust-toolchain.toml

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ components = [
77
"rustfmt",
88
"rust-src",
99
]
10+
targets = [ "x86_64-unknown-none" ]

xtask/src/main.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ const RUSTFLAGS: &[&str] = &[
1919
"-Zmutable-noalias=no",
2020
];
2121

22-
const KERNEL_CARGO_ARGS: &[&str] = &[
23-
"-Zbuild-std=core,alloc",
24-
"-Zbuild-std-features=compiler-builtins-mem",
25-
];
26-
2722
fn main() -> Result<()> {
2823
flags::Xtask::from_env()?.run()
2924
}
@@ -48,8 +43,7 @@ impl flags::Build {
4843
eprintln!("Building kernel");
4944
cmd!(sh, "cargo build")
5045
.env("CARGO_ENCODED_RUSTFLAGS", self.cargo_encoded_rustflags()?)
51-
.args(KERNEL_CARGO_ARGS)
52-
.arg(target_arg(&self.arch)?)
46+
.args(target_args(&self.arch)?)
5347
.args(self.target_dir_args())
5448
.args(self.no_default_features_args())
5549
.args(self.features_args())
@@ -226,12 +220,12 @@ impl flags::Clippy {
226220
// https://github.com/hermitcore/libhermit-rs/issues/381
227221
#[allow(clippy::single_element_loop)]
228222
for target in ["x86_64"] {
229-
let target_arg = target_arg(target)?;
230-
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}").run()?;
231-
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}")
223+
let target_arg = target_args(target)?;
224+
cmd!(sh, "cargo clippy {target_arg...}").run()?;
225+
cmd!(sh, "cargo clippy {target_arg...}")
232226
.arg("--no-default-features")
233227
.run()?;
234-
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}")
228+
cmd!(sh, "cargo clippy {target_arg...}")
235229
.arg("--all-features")
236230
.run()?;
237231
}
@@ -244,15 +238,22 @@ impl flags::Clippy {
244238

245239
fn target(arch: &str) -> Result<&'static str> {
246240
match arch {
247-
"x86_64" => Ok("x86_64-unknown-none-hermitkernel"),
241+
"x86_64" => Ok("x86_64-unknown-none"),
248242
"aarch64" => Ok("aarch64-unknown-none-hermitkernel"),
249243
arch => Err(anyhow!("Unsupported arch: {arch}")),
250244
}
251245
}
252246

253-
fn target_arg(arch: &str) -> Result<String> {
254-
let target = target(arch)?;
255-
Ok(format!("--target=targets/{target}.json"))
247+
fn target_args(arch: &str) -> Result<&'static [&'static str]> {
248+
match arch {
249+
"x86_64" => Ok(&["--target=x86_64-unknown-none"]),
250+
"aarch64" => Ok(&[
251+
"--target=targets/aarch64-unknown-none-hermitkernel.json",
252+
"-Zbuild-std=core,alloc",
253+
"-Zbuild-std-features=compiler-builtins-mem",
254+
]),
255+
arch => Err(anyhow!("Unsupported arch: {arch}")),
256+
}
256257
}
257258

258259
fn binutil(name: &str) -> Result<PathBuf> {

0 commit comments

Comments
 (0)