|
| 1 | +# `*-unknown-helenos` |
| 2 | + |
| 3 | +**Tier: 3** |
| 4 | + |
| 5 | +Targets for [HelenOS](https://www.helenos.org). |
| 6 | +These targets allow compiling user-space applications, that you can then copy into your HelenOS ISO image to run them. |
| 7 | + |
| 8 | +Target triplets available so far: |
| 9 | + |
| 10 | +- `x86_64-unknown-helenos` |
| 11 | +- `i686-unknown-helenos` |
| 12 | + |
| 13 | +## Target maintainers |
| 14 | + |
| 15 | +- Matěj Volf ([@mvolfik](https://github.com/mvolfik)) |
| 16 | + |
| 17 | +## Requirements |
| 18 | + |
| 19 | +These targets only support cross-compilation. The targets will[^1] support libstd, although support of some platform features (filesystem, networking) may be limited. |
| 20 | + |
| 21 | +You need to have a local clone of the HelenOS repository and the HelenOS toolchain set up, no HelenOS-Rust development artifacts are available. |
| 22 | + |
| 23 | +[^1]: The support is not yet available, because it needs to be done in a separate PR, because compiler support needs to be merged first to allow creating libc bindings |
| 24 | + |
| 25 | +## Building |
| 26 | + |
| 27 | +### HelenOS toolchain setup |
| 28 | + |
| 29 | +For compilation of standard library, you need to build the HelenOS toolchain (because Rust needs to use `*-helenos-gcc` as linker) and shared libraries. See [this HelenOS wiki page](https://www.helenos.org/wiki/UsersGuide/CompilingFromSource#a2.Buildasupportedcross-compiler) for instruction on setting up the build. At the end of step 4 (_Configure and build_), invoke `ninja export-dev` to build the shared libraries. |
| 30 | + |
| 31 | +Then copy these shared libraries from `export-dev/lib` to the path where the compiler automatically searches for them. This will be the directory where you installed the toolchain (for example `~/.local/share/HelenOS/cross/i686-helenos/lib`). You can see this path with this command: |
| 32 | + |
| 33 | +```sh |
| 34 | +touch /tmp/test.c |
| 35 | +i686-helenos-gcc -v -c /tmp/test.c 2>&1 | grep LIBRARY_PATH |
| 36 | +``` |
| 37 | + |
| 38 | +## Building the target |
| 39 | + |
| 40 | +When you have the HelenOS toolchain set up and installed in your path, you can build the Rust toolchain using the standard procedure. See [rustc dev guide](https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html). |
| 41 | + |
| 42 | +## Building Rust programs |
| 43 | + |
| 44 | +No special setup is needed. Simply use the toolchain you built above and run `cargo build --target <arch>-unknown-helenos`. |
| 45 | + |
| 46 | +## Testing |
| 47 | + |
| 48 | +Running the Rust test suite has not been attempted yet. |
| 49 | + |
| 50 | +## Cross-compilation toolchains and C code |
| 51 | + |
| 52 | +You should be able to cross-compile and link any needed C code using `<arch>-helenos-gcc` that you built above. However, note that clang support is highly lacking. Therefore, to run tools such as `bindgen`, you will need to provide flag `-nostdinc` and manually specify the include paths to HelenOS headers, which you will find in the `export-dev` + in the cross-compilation toolchain (e.g. `~/.local/share/HelenOS/cross/lib/gcc/i686-helenos/14.2.0/include`). |
0 commit comments