arceos-helloworld-0.3.0 is not a library.
arceos-helloworld
A standalone Hello World application running on ArceOS unikernel, with all dependencies sourced from crates.io. Supports multiple architectures via cargo xtask.
Supported Architectures
| Architecture | Rust Target | QEMU Machine | Platform |
|---|---|---|---|
| riscv64 | riscv64gc-unknown-none-elf |
qemu-system-riscv64 -machine virt |
riscv64-qemu-virt |
| aarch64 | aarch64-unknown-none-softfloat |
qemu-system-aarch64 -machine virt |
aarch64-qemu-virt |
| x86_64 | x86_64-unknown-none |
qemu-system-x86_64 -machine q35 |
x86-pc |
| loongarch64 | loongarch64-unknown-none |
qemu-system-loongarch64 -machine virt |
loongarch64-qemu-virt |
Prerequisites
-
Rust nightly toolchain (edition 2024)
-
Bare-metal targets (install the ones you need)
-
QEMU (install the emulators for your target architectures)
# Ubuntu/Debian # macOS (Homebrew) -
rust-objcopy (from
cargo-binutils, required for non-x86_64 targets)
Quick Start
# Build and run on RISC-V 64 QEMU (default)
# Build and run on other architectures
# Build only (no QEMU)
Expected output (riscv64 example):
d8888 .d88888b. .d8888b.
d88888 d88P" "Y88b d88P Y88b
...
d88P 888 888 "Y8888P "Y8888 "Y88888P" "Y8888P"
arch = riscv64
platform = riscv64-qemu-virt
...
smp = 1
Hello, world!
QEMU will automatically exit after printing the message.
Project Structure
app-helloworld/
├── .cargo/
│ └── config.toml # cargo xtask alias & AX_CONFIG_PATH
├── xtask/
│ ├── Cargo.toml # xtask build tool (clap CLI)
│ └── src/
│ └── main.rs # build/run subcommand implementation
├── configs/
│ ├── riscv64.toml # Platform config for RISC-V 64 QEMU virt
│ ├── aarch64.toml # Platform config for AArch64 QEMU virt
│ ├── x86_64.toml # Platform config for x86-64 PC
│ └── loongarch64.toml # Platform config for LoongArch64 QEMU virt
├── src/
│ └── main.rs # Application entry point
├── build.rs # Linker script path setup (auto-detects arch)
├── Cargo.toml # Dependencies (axstd from crates.io)
└── README.md
How It Works
The cargo xtask pattern uses a host-native helper crate (xtask/) to orchestrate
cross-compilation and QEMU execution:
-
cargo xtask build --arch <ARCH>- Copies
configs/<ARCH>.tomlto.axconfig.toml(platform configuration) - Runs
cargo build --release --target <TARGET> build.rsauto-detects the architecture and locates the correct linker script
- Copies
-
cargo xtask run --arch <ARCH>- Performs the build step above
- Converts ELF to raw binary via
rust-objcopy(except x86_64 which uses ELF directly) - Launches the appropriate QEMU emulator with architecture-specific flags
Key Components
| Component | Role |
|---|---|
axstd |
ArceOS standard library (replaces Rust's std in no_std environment) |
axhal |
Hardware abstraction layer, generates the linker script at build time |
axplat-* |
Platform-specific support crates (one per target board/VM) |
axruntime |
Kernel initialization and runtime setup |
build.rs |
Locates the linker script generated by axhal and passes it to the linker |
configs/*.toml |
Pre-generated platform configuration for each architecture |
License
GPL-3.0-or-later OR Apache-2.0 OR MulanPSL-2.0