Skip to content
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
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Copyright 2024, UNSW
# SPDX-License-Identifier: BSD-2-Clause

## Microkit Tool ##
[target.aarch64-unknown-linux-musl]
rustflags = ["-Clinker=rust-lld"]

[target.x86_64-unknown-linux-musl]
rustflags = ["-Clinker=rust-lld"]

## Initialiser ##
[target.x86_64-unknown-none]
rustflags = ["-C", "relocation-model=static"]
3 changes: 3 additions & 0 deletions .github/workflows/sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ jobs:
rustup default 1.94.0
rustup target add x86_64-unknown-linux-musl
rustup component add rust-src --toolchain 1.94.0-x86_64-unknown-linux-gnu
rustup target add aarch64-unknown-none
rustup target add riscv64gc-unknown-none-elf
rustup target add x86_64-unknown-none
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
Expand Down
14 changes: 6 additions & 8 deletions build_sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ def target_triple(self) -> str:

def rust_toolchain(self) -> str:
if self == KernelArch.AARCH64:
return f"{self.to_str()}-sel4-minimal"
return f"aarch64-unknown-none"
elif self == KernelArch.RISCV64:
return f"{self.to_str()}imac-sel4-minimal"
return f"riscv64gc-unknown-none-elf"
elif self == KernelArch.X86_64:
return f"{self.to_str()}-sel4-minimal"
return f"x86_64-unknown-none"
else:
raise Exception(f"Unsupported toolchain target triple '{self}'")

Expand Down Expand Up @@ -804,9 +804,7 @@ def build_initialiser(
) -> None:
sel4_src_dir = build_dir / board.name / config.name / "sel4" / "install"

cargo_cross_options = "-Z build-std=core,alloc,compiler_builtins -Z build-std-features=compiler-builtins-mem"
cargo_target = board.arch.rust_toolchain()
rust_target_path = Path("initialiser/support/targets").absolute()

dest = (
root_dir / "board" / board.name / config.name / "elf" / f"{component_name}.elf"
Expand All @@ -819,11 +817,10 @@ def build_initialiser(
component_build_dir = build_dir / board.name / config.name / component_name
component_build_dir.mkdir(exist_ok=True, parents=True)

capdl_init_elf = rust_target_dir / cargo_target / "release" / "initialiser.elf"
r = system(f"""
RUSTC_BOOTSTRAP=1 \
RUST_TARGET_PATH={rust_target_path} SEL4_PREFIX={sel4_src_dir.absolute()} \
cargo build {cargo_cross_options} \
SEL4_PREFIX={sel4_src_dir.absolute()} \
cargo build \
--target {cargo_target} \
--locked \
--target-dir {rust_target_dir} \
Expand All @@ -836,6 +833,7 @@ def build_initialiser(
)

dest.unlink(missing_ok=True)
capdl_init_elf = rust_target_dir / cargo_target / "release" / "initialiser"
shutil.copy(capdl_init_elf, dest)
# Make output read-only
dest.chmod(0o744)
Expand Down
9 changes: 8 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@
aarch64-linux = [];
}.${system} or (throw "Unsupported system: ${system}");

# For the initialiser
crossTargets = [
"aarch64-unknown-none"
"riscv64gc-unknown-none-elf"
"x86_64-unknown-none"
];

rustTool = pkgs.rust-bin.stable.${microkitToolVersion}.default.override {
extensions = [ "rust-src" ];
targets = [ pkgs.pkgsStatic.stdenv.hostPlatform.rust.rustcTarget ] ++ rustAdditionalTargets;
targets = [ pkgs.pkgsStatic.stdenv.hostPlatform.rust.rustcTarget ] ++ rustAdditionalTargets ++ crossTargets;
};
in
{
Expand Down
34 changes: 0 additions & 34 deletions initialiser/support/targets/aarch64-sel4-minimal.json

This file was deleted.

28 changes: 0 additions & 28 deletions initialiser/support/targets/riscv64imac-sel4-minimal.json

This file was deleted.

32 changes: 0 additions & 32 deletions initialiser/support/targets/x86_64-sel4-minimal.json

This file was deleted.

Loading