|
| 1 | +# `aarch64-unknown-none-hermitkernel` |
| 2 | + |
| 3 | +**Tier: 3** |
| 4 | + |
| 5 | +Required to build the kernel for [HermitCore](https://github.com/hermitcore/hermit-playground) |
| 6 | +or [RustyHermit](https://github.com/hermitcore/rusty-hermit). |
| 7 | +The result is a bare-metal aarch64 binary in ELF format. |
| 8 | + |
| 9 | +## Target maintainers |
| 10 | + |
| 11 | +- Stefan Lankes, https://github.com/stlankes |
| 12 | + |
| 13 | +## Requirements |
| 14 | + |
| 15 | +This target is cross-compiled. There is no support for `std`, but the |
| 16 | +library operating system provides a simple allocator to use `alloc`. |
| 17 | + |
| 18 | +By default, Rust code generated for this target does not use any vector or |
| 19 | +floating-point registers. This allows the generated code to build the library |
| 20 | +operaring system, which may need to avoid the use of such |
| 21 | +registers or which may have special considerations about the use of such |
| 22 | +registers (e.g. saving and restoring them to avoid breaking userspace code |
| 23 | +using the same registers). In contrast to `aarch64-unknown-none-softfloat`, |
| 24 | +the target is completly relocatable, which is a required feature of RustyHermit. |
| 25 | + |
| 26 | +By default, code generated with this target should run on any `aarch64` |
| 27 | +hardware; enabling additional target features may raise this baseline. |
| 28 | +On `aarch64-unknown-none-hermitkernel`, `extern "C"` uses the [standard System V calling |
| 29 | +convention](https://github.com/ARM-software/abi-aa/releases/download/2021Q3/sysvabi64.pdf), |
| 30 | +without red zones. |
| 31 | + |
| 32 | +This target generated binaries in the ELF format. |
| 33 | + |
| 34 | +## Building the target |
| 35 | + |
| 36 | +Typical you should not use the target directly. The target `aarch64-unknown-hermit` |
| 37 | +builds the _user space_ of RustyHermit and supports red zones and floating-point |
| 38 | +operations. |
| 39 | +To build and link the kernel to the application, the crate |
| 40 | +[hermit-sys](https://github.com/hermitcore/rusty-hermit/tree/master/hermit-sys) |
| 41 | +should be used by adding the following lines to the `Cargo.toml` file of |
| 42 | +your application. |
| 43 | + |
| 44 | +```toml |
| 45 | +[target.'cfg(target_os = "hermit")'.dependencies] |
| 46 | +hermit-sys = "0.1.*" |
| 47 | +``` |
| 48 | + |
| 49 | +The crate `hermit-sys` uses the target `aarch64-unknown-none-hermitkernel` |
| 50 | +to build the kernel. |
| 51 | + |
| 52 | +## Building Rust programs |
| 53 | + |
| 54 | +Rust does not yet ship pre-compiled artifacts for this target. To compile for |
| 55 | +this target, you need to build the crate `hermit-sys` (see |
| 56 | +"Building the target" above). |
| 57 | + |
| 58 | +## Testing |
| 59 | + |
| 60 | +As `aarch64-unknown-none-hermitkernel` does not support `std` |
| 61 | +and does not support running any Rust testsuite. |
| 62 | + |
| 63 | +## Cross-compilation toolchains and C code |
| 64 | + |
| 65 | +If you want to compile C code along with Rust you will need an |
| 66 | +appropriate `aarch64` toolchain. |
| 67 | + |
| 68 | +Rust *may* be able to use an `aarch64-linux-gnu-` toolchain with appropriate |
| 69 | +standalone flags to build for this toolchain (depending on the assumptions of |
| 70 | +that toolchain, see below), or you may wish to use a separate |
| 71 | +`aarch64-unknown-none` (or `aarch64-elf-`) toolchain. |
| 72 | + |
| 73 | +On some `aarch64` hosts that use ELF binaries, you *may* be able to use the host |
| 74 | +C toolchain, if it does not introduce assumptions about the host environment |
| 75 | +that don't match the expectations of a standalone environment. Otherwise, you |
| 76 | +may need a separate toolchain for standalone/freestanding development, just as |
| 77 | +when cross-compiling from a non-`aarch64` platform. |
0 commit comments