Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to x86_64-unknown-none #430

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ ENV RUSTUP_HOME=/usr/local/rustup \
PATH=/usr/local/cargo/bin:$PATH \
# Manually sync this with rust-toolchain.toml!
RUST_VERSION=nightly-2022-04-24 \
RUST_COMPONENTS="clippy llvm-tools-preview rustfmt rust-src"
RUST_COMPONENTS="clippy llvm-tools-preview rustfmt rust-src" \
RUST_TARGETS="x86_64-unknown-none"

RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
Expand All @@ -26,6 +27,7 @@ RUN set -eux; \
--default-toolchain $RUST_VERSION \
--default-host ${rustArch} \
--component $RUST_COMPONENTS \
--target $RUST_TARGETS \
; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
Expand Down
1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ components = [
"rustfmt",
"rust-src",
]
targets = [ "x86_64-unknown-none" ]
31 changes: 16 additions & 15 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ const RUSTFLAGS: &[&str] = &[
"-Zmutable-noalias=no",
];

const KERNEL_CARGO_ARGS: &[&str] = &[
"-Zbuild-std=core,alloc",
"-Zbuild-std-features=compiler-builtins-mem",
];

fn main() -> Result<()> {
flags::Xtask::from_env()?.run()
}
Expand All @@ -48,8 +43,7 @@ impl flags::Build {
eprintln!("Building kernel");
cmd!(sh, "cargo build")
.env("CARGO_ENCODED_RUSTFLAGS", self.cargo_encoded_rustflags()?)
.args(KERNEL_CARGO_ARGS)
.arg(target_arg(&self.arch)?)
.args(target_args(&self.arch)?)
.args(self.target_dir_args())
.args(self.no_default_features_args())
.args(self.features_args())
Expand Down Expand Up @@ -226,12 +220,12 @@ impl flags::Clippy {
// https://github.com/hermitcore/libhermit-rs/issues/381
#[allow(clippy::single_element_loop)]
for target in ["x86_64"] {
let target_arg = target_arg(target)?;
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}").run()?;
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}")
let target_arg = target_args(target)?;
cmd!(sh, "cargo clippy {target_arg...}").run()?;
cmd!(sh, "cargo clippy {target_arg...}")
.arg("--no-default-features")
.run()?;
cmd!(sh, "cargo clippy {KERNEL_CARGO_ARGS...} {target_arg}")
cmd!(sh, "cargo clippy {target_arg...}")
.arg("--all-features")
.run()?;
}
Expand All @@ -244,15 +238,22 @@ impl flags::Clippy {

fn target(arch: &str) -> Result<&'static str> {
match arch {
"x86_64" => Ok("x86_64-unknown-none-hermitkernel"),
"x86_64" => Ok("x86_64-unknown-none"),
"aarch64" => Ok("aarch64-unknown-none-hermitkernel"),
arch => Err(anyhow!("Unsupported arch: {arch}")),
}
}

fn target_arg(arch: &str) -> Result<String> {
let target = target(arch)?;
Ok(format!("--target=targets/{target}.json"))
fn target_args(arch: &str) -> Result<&'static [&'static str]> {
match arch {
"x86_64" => Ok(&["--target=x86_64-unknown-none"]),
"aarch64" => Ok(&[
"--target=targets/aarch64-unknown-none-hermitkernel.json",
"-Zbuild-std=core,alloc",
"-Zbuild-std-features=compiler-builtins-mem",
]),
arch => Err(anyhow!("Unsupported arch: {arch}")),
}
}

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