Add repo-relative linker config
Some checks failed
Basic Cargo Checks / docker-check (push) Successful in 1m22s
Basic Cargo Checks / docker-build (push) Failing after 11m3s

This commit is contained in:
Blizzard Finnegan 2023-06-22 07:08:59 -04:00
parent c0d13009a4
commit 7aa23f4015
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E
2 changed files with 5 additions and 19 deletions

2
.cargo/config.toml Normal file
View file

@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-musl]
linker = "lld"

View file

@ -45,13 +45,11 @@ You can also build without the `--release` flag, which wil take less time, but w
## Cross-Compilation
Cross compilation is possible with this project, if you do not have a Raspberry Pi available specifically for compilation. Compilation directly on the Pi is rather intensive, and takes significantly longer than cross-compiling. However, cross-compiling by default will fail, due to a bad linker.
Cross compilation is possible with this project, if you do not have a Raspberry Pi available specifically for compilation. Compilation directly on the Pi is rather intensive, and takes significantly longer than cross-compiling.
To resolve this issue, find the `.cargo` folder. For Windows users, it is located in `C:\Users\[username]`, and for Linux users it is located in `~` or `$HOME`. If you are on Linux, you will need to be sure to show hidden files.
If you are compiling on Linux, cross-compilation has a dependency of `lld`. This can be found in your distribution's package manager, or directly distributed by LLVM.
In this `.cargo` folder, create a new file, named `config`. In it, add the following lines in the relevant sections below.
Once this file is added, you can then run one of the following commands to create the executable. Note that the final executable will be in `target/aarch64-unknown-linux-musl`, rather than `target`.
If you are compiling on Windows, to safely cross-compile, you must modify the `.cargo/config.toml` file. Replace `lld` with `rust-lld`, then cross-compilation should work properly.
```bash
cargo build --target aarch64-unknown-linux-musl
@ -59,18 +57,4 @@ cargo build --target aarch64-unknown-linux-musl
cargo build --release --target aarch64-unknown-linux-musl
```
#### Windows
```toml
[target.aarch64-unknown-linux-musl]
linker = rust-lld
```
#### Linux
```toml
[target.aarch64-unknown-linux-musl]
linker = lld
```
Make sure `lld` is installed as well. This can be found in your distribution's package manager, or directly distributed by LLVM.