From a0a0c41cc3730f2154c4c019b7a3a2bc0397d5a5 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Wed, 5 Jun 2024 15:01:45 +0200 Subject: [PATCH 1/2] toolchain: add config for cargo build-std (unstable) we need to build the toolchain because qkernel (arch-qkernel.json) is not one of the default targets. We have been using the cargo-xbuild tool for this and it worked fine, however it's not under active maintance for ~ 2 years and there could be some issues with newer rust toolchain as of May, 2024. Rust's build-std is a unstable feature that does the same thing: we tell it to build the components e.g. core, alloc, builtins ... in the .cargo/config.toml so that cargo builds them with the custom target specified by `--target xyz.json`. To use this, simply replace the `cargo xbuild` with `cargo build` in qkernel's makefile, nothing else needs to change. (this approach is also noted in cargo-xbuild's docs) Since cargo xbuild is not breaking (yet) and the build-std is not a unstable feature (yet), I'm keeping the cargo-xbuild as default. The build-std could opt-in if needed. Signed-off-by: Tianhao Wang --- qkernel/.cargo/config.toml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 qkernel/.cargo/config.toml diff --git a/qkernel/.cargo/config.toml b/qkernel/.cargo/config.toml new file mode 100644 index 000000000..2abd7719a --- /dev/null +++ b/qkernel/.cargo/config.toml @@ -0,0 +1,3 @@ +[unstable] +build-std = ["core","alloc", "compiler_builtins"] +build-std-features = ["compiler-builtins-mem"] From 2f6247a96acb44852b23da29228eef2902afa106 Mon Sep 17 00:00:00 2001 From: Tianhao Wang Date: Thu, 6 Jun 2024 18:04:09 +0200 Subject: [PATCH 2/2] toolchain: replace cargo-xbuild with build-std Signed-off-by: Tianhao Wang --- qkernel/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qkernel/makefile b/qkernel/makefile index a373eef84..b8131ccdc 100644 --- a/qkernel/makefile +++ b/qkernel/makefile @@ -25,10 +25,10 @@ $(kernel_debug): kernel_debug $(assembly_object_files) $(assembly_object_files) $(qkernel_debug) kernel: - CARGO_TARGET_DIR=../target cargo +$(TOOLCHAIN) xbuild --target $(arch)-qkernel.json --release + CARGO_TARGET_DIR=../target cargo +$(TOOLCHAIN) build --target $(arch)-qkernel.json --release kernel_debug: - CARGO_TARGET_DIR=../target cargo +$(TOOLCHAIN) xbuild --target $(arch)-qkernel.json + CARGO_TARGET_DIR=../target cargo +$(TOOLCHAIN) build --target $(arch)-qkernel.json ../build/arch/$(arch)/%.o: src/qlib/kernel/arch/$(arch)/%.s @mkdir -p $(shell dirname $@)