Add compilation section with cross-compilation instructions

This commit is contained in:
mycognosist
2020-05-19 10:59:37 +01:00
parent 13873ab50c
commit 9657c5d811
2 changed files with 39 additions and 0 deletions

View File

@ -17,6 +17,7 @@
- [peach-stats](./software/microservices/peach-stats.md)
- [Web Interface](./software/web_interface.md)
- [Pattern Library](./software/pattern_library.md)
- [Compilation](./software/compilation.md)
- [Packaging](./software/packaging.md)
- [Configuration](./software/configuration.md)
- [Contributor's Guide](./contributors_guide.md)

View File

@ -0,0 +1,38 @@
# Compilation
Since the majority of PeachCloud is written in the Rust programming language, a compiler and associated toolchain(s) is required to build the software from source. Visit the [rustup](https://rustup.rs/) website to download the Rust toolchain installer. In addition to the default `stable` installation of Rust, many PeachCloud crates require the `nightly` toolchain channel in order to compile. Instructions for installing and updating toolchains can be found in the README of the [rustup GitHub repo](https://github.com/rust-lang/rustup).
## Cross-Compilation
While PeachCloud crates can be compiled directly on the Raspberry Pi or equivalent single board computer, this process is resource intensive and relatively slow - especially when compiling release builds. Cross-compilation is an effective means of leveraging greater compute resources to reduce compilation time.
These instructions cover cross-compilation for Debian Buster running on a Raspberry Pi 3B+, using a host machine running Debian Stretch with an x86_64 architecture:
**Install target platform:**
`rustup target add aarch64-unknown-linux-gnu`
**Install toolchain:**
`rustup toolchain install nightly-aarch64-unknown-linux-gnu`
**Install aarch64-linux-gnu-gcc:**
`sudo apt-get install gcc-aarch64-linux-gnu`
**Configure the linker:**
`export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=/usr/bin/aarch64-linux-gnu-gcc`
Alternatively, create a file named `cargo-config` in the root directory of the crate and add the following:
```bash
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
```
**Compile release build:**
`cargo build --release --target=aarch64-unknown-linux-gnu`
The generated binary will be saved at `target/aarch64-unknown-linux-gnu/release/name_of_crate`