From cba2b17f57a53d067a15df34992e58e1d7162c72 Mon Sep 17 00:00:00 2001 From: Nahuel Lofeudo Date: Mon, 25 May 2026 09:49:26 +0100 Subject: [PATCH] Partial migration of cross-compilation from `cross` to Cargo. --- Cargo.toml | 17 ++++++++++++++++- Cross.toml | 8 -------- readme.md | 31 +++++++++++++++++++------------ 3 files changed, 35 insertions(+), 21 deletions(-) delete mode 100644 Cross.toml diff --git a/Cargo.toml b/Cargo.toml index 89edd9b..fcc1a40 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,22 @@ yaml_serde = "0.10" zip = "8.3" [profile.dev] -opt-level = 3 +opt-level = 1 [profile.release] opt-level = 3 + +[target.aarch64-unknown-linux-gnu] +cc = "aarch64-linux-gnu-gcc" +cxx = "aarch64-linux-gnu-g++" +ar = "aarch64-linux-gnu-ar" +# ranlib = "aarch64-linux-gnu-ranlib" +linker = "aarch64-linux-gnu-gcc" + + +[target.arm-unknown-linux-gnueabihf] +cc = "arm-linux-gnueabihf-gcc" +cxx = "arm-linux-gnueabihf-g++" +ar = "arm-linux-gnueabihf-ar" +# ranlib = "arm-linux-gnueabihf-ranlib" +linker = "arm-linux-gnueabihf-gcc" \ No newline at end of file diff --git a/Cross.toml b/Cross.toml deleted file mode 100644 index 898c929..0000000 --- a/Cross.toml +++ /dev/null @@ -1,8 +0,0 @@ -[build] -default-target = "aarch64-unknown-linux-gnu" # use this target if none is explicitly provided -pre-build = [ # additional commands to run prior to building the package - "dpkg --add-architecture $CROSS_DEB_ARCH", - "apt update", - "apt --assume-yes install apt-utils:$CROSS_DEB_ARCH", - "apt --assume-yes install libsdl3-dev:$CROSS_DEB_ARCH" -] \ No newline at end of file diff --git a/readme.md b/readme.md index 5aa5219..43f5681 100644 --- a/readme.md +++ b/readme.md @@ -6,21 +6,28 @@ ## Install ARM toolchains: -``` -cargo install cross -rustup target add aarch64-unknown-linux-gnu # 64-bit Pi OS -rustup target add armv7-unknown-linux-gnueabihf # 32-bit Pi 2/3/4 OS -rustup target add arm-unknown-linux-gnueabihf # ARMv6 (Pi Zero/1) +```bash +$ rustup target add aarch64-unknown-linux-gnu +$ rustup target add arm-unknown-linux-gnueabihf -sudo apt-get update -sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf + +$ sudo dpkg --add-architecture arm64 +$ sudo dpkg --add-architecture armhf + +$ sudo apt update +$ sudo apt-get install gcc-aarch64-linux-gnu gcc-arm-linux-gnueabihf \ + libc6-arm64-cross libc6-dev-arm64-cross gcc-aarch64-linux-gnu \ + libc6-armhf-cross libc6-dev-armhf-cross gcc-arm-linux-gnueabihf \ + libssl-dev libssl-dev:arm64 libsdl3-dev:arm64 libssl-dev:armhf libsdl3-dev:armhf ``` ## Cross-compile -``` -# 2) Build -~/.cargo/bin/cross build --target aarch64-unknown-linux-gnu --release -~/.cargo/bin/cross build --target armv7-unknown-linux-gnueabihf --release -~/.cargo/bin/cross build --target arm-unknown-linux-gnueabihf --release +ARM64 +```bash +$ export PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu/ +$ cargo build --target aarch64-unknown-linux-gnu --release + +$ export PKG_CONFIG_SYSROOT_DIR=/usr/arm-linux-gnueabihf/ +$ cargo build --target arm-unknown-linux-gnueabihf --release ``` \ No newline at end of file