From a6e168594d6a3ec1b02ed4cdda3dc7983e471d06 Mon Sep 17 00:00:00 2001 From: Eric Van Albert Date: Thu, 27 Nov 2025 14:25:08 -0500 Subject: [PATCH] Update script to build aarch64-linux --- .github/scripts/build.sh | 61 +++++++++++++++++++++++++++++----------- Cargo.toml | 4 +-- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/.github/scripts/build.sh b/.github/scripts/build.sh index 378c197a..7f567ad3 100755 --- a/.github/scripts/build.sh +++ b/.github/scripts/build.sh @@ -3,8 +3,38 @@ set -euo pipefail # Usage: TARGET=x86_64-pc-windows-gnu ./generate-rustflags.sh +# Set linkers for cross-compilation targets using clang + +case "$TARGET" in + x86_64-unknown-linux-gnu) + OS=LINUX + EXE=radiance + STRIP=strip + export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER="gcc" + ;; + aarch64-unknown-linux-gnu) + OS=LINUX + EXE=radiance + STRIP=aarch64-linux-gnu-strip + export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER="aarch64-linux-gnu-gcc" + ;; + x86_64-pc-windows-gnu) + OS=WINDOWS + EXE=radiance.exe + STRIP=x86_64-w64-mingw32-strip + ;; + *) + echo "Unknown TARGET" >&2 + exit 1 + ;; +esac + +LIBMPV_STATIC_BUILD="$(cd "../libmpv-static-build" && pwd)" + # Set PKG_CONFIG_PATH based on target -export PKG_CONFIG_PATH="../libmpv-static-build/${TARGET}/output/lib/pkgconfig" +export PKG_CONFIG_LIBDIR="${LIBMPV_STATIC_BUILD}/${TARGET}/output/lib/pkgconfig" +export PKG_CONFIG_PATH="$PKG_CONFIG_LIBDIR" +export PKG_CONFIG_ALLOW_CROSS=1 # Get all the static library dependencies LIBS=$(pkg-config --static --libs mpv) @@ -23,8 +53,8 @@ for flag in $LIBS; do done # Platform-specific linking -case "$TARGET" in - x86_64-pc-windows-gnu) +case "$OS" in + WINDOWS) RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,--allow-multiple-definition" # Wrap all static libraries in a group to resolve circular dependencies RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,-Bstatic" @@ -49,22 +79,18 @@ case "$TARGET" in RUSTFLAGS="$RUSTFLAGS -C link-arg=-ladvapi32" RUSTFLAGS="$RUSTFLAGS -C link-arg=-lshell32" RUSTFLAGS="$RUSTFLAGS -C link-arg=-lole32" - - export RUSTFLAGS - echo "Generated RUSTFLAGS: $RUSTFLAGS" - - cargo build --release --target "$TARGET" - x86_64-w64-mingw32-strip "target/${TARGET}/release/radiance.exe" ;; - x86_64-unknown-linux-gnu) + LINUX) RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,-Bstatic" RUSTFLAGS="$RUSTFLAGS -C link-arg=-lstdc++" + RUSTFLAGS="$RUSTFLAGS -C link-arg=-lgcc" RUSTFLAGS="$RUSTFLAGS -C link-arg=-Wl,-Bdynamic" # Populate /tmp/native-lib-pc with fake pkg-config files so we only dynamically link the things we want to rm -rf /tmp/native-lib-pc/ mkdir -p /tmp/native-lib-pc/ + # Skip linker flags for mpv since we need more fine-grained control over it cat </tmp/native-lib-pc/mpv.pc Name: mpv Description: placeholder @@ -89,16 +115,17 @@ Cflags: Libs: -lasound EOF - export RUSTFLAGS - echo "Generated RUSTFLAGS: $RUSTFLAGS" - - PKG_CONFIG_LIBDIR="/tmp/native-lib-pc/" \ - PKG_CONFIG_PATH="/tmp/native-lib-pc/" \ - cargo build --release --target "$TARGET" - strip "target/${TARGET}/release/radiance" + #PKG_CONFIG_LIBDIR="/tmp/native-lib-pc/" \ + #PKG_CONFIG_PATH="/tmp/native-lib-pc/" \ ;; *) echo "Unknown target: $TARGET" >&2 exit 1 ;; esac + +export RUSTFLAGS +echo "Generated RUSTFLAGS: $RUSTFLAGS" + +cargo build --release --target "$TARGET" +$STRIP "target/${TARGET}/release/${EXE}" diff --git a/Cargo.toml b/Cargo.toml index f959c753..c4740a01 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,8 +46,8 @@ image = "0.24" directories = "6.0.0" # mpv / MovieNode dependencies -libmpv = { git = "https://github.com/ervanalb/libmpv-rs", rev = "8f79ae86411ff4226288c836e18fbc80b0f636fb", features = ["render"]} -libmpv-sys = { git = "git+https://github.com/ervanalb/libmpv-rs", rev="8f79ae86411ff4226288c836e18fbc80b0f636fb"} +libmpv = { git = "https://github.com/ervanalb/libmpv-rs", rev = "189f5e45df40ec72cc9047e0b5ccb8b457b9735a", features = ["render"]} +libmpv-sys = { git = "git+https://github.com/ervanalb/libmpv-rs", rev="189f5e45df40ec72cc9047e0b5ccb8b457b9735a"} surfman = { version = "0.7.0", features = ["sm-x11"] } glow = "0.12.1" crossbeam = "0.8.2"