mononix/Mononix/Cross-compiling.md

31 lines
873 B
Markdown

# 2023-07-09
I did some basic things to cross-compile to raspberry pi, and I got an executable that would theoretically run on a Pi. However, the Pi is a Nixos system, so I'll need to either create a full enclosure of my dev environment, or I will need to patchelf anything that I copy over. Patchelf is not impossible, but it's not as easy as just copying the executable from one system to another.
rust-toolchain:
```
[toolchain]
channel = "1.68.2"
targets = [ "wasm32-unknown-unknown", "arm-unknown-linux-gnueabihf" ]
```
.cargo/config.toml:
```
[target.arm-unknown-linux-gnueabihf]
linker = "armv6l-unknown-linux-gnueabihf-gcc"
```
flake.nix:
```
armPkgs = import nixpkgs {
system = "x86_64-linux";
crossSystem = pkgs.lib.systems.examples.raspberryPi;
};
...
buildInputs = [
armPkgs.stdenv.cc
]
```