From abb2e5a95a2edd4804dad24517f596c92434d3ce Mon Sep 17 00:00:00 2001 From: tsukumi Date: Tue, 10 May 2022 07:37:42 +0900 Subject: [PATCH] Fix build scripts to be able to build with linuxarm64 image --- scripts.d/25-fftw3.sh | 11 ++++++++--- scripts.d/25-openssl.sh | 5 +++++ scripts.d/50-libvpx.sh | 7 ++++++- scripts.d/50-openh264.sh | 5 +++++ scripts.d/50-rav1e.sh | 6 ++++++ scripts.d/50-vidstab.sh | 7 ++++++- 6 files changed, 36 insertions(+), 5 deletions(-) diff --git a/scripts.d/25-fftw3.sh b/scripts.d/25-fftw3.sh index 662b05e..f568c9e 100755 --- a/scripts.d/25-fftw3.sh +++ b/scripts.d/25-fftw3.sh @@ -29,11 +29,16 @@ ffbuild_dockerbuild() { --enable-threads --with-combined-threads --with-incoming-stack-boundary=2 - --enable-sse2 - --enable-avx - --enable-avx2 ) + if [[ $TARGET != linuxarm64 ]]; then + myconf+=( + --enable-sse2 + --enable-avx + --enable-avx2 + ) + fi + if [[ $TARGET == win* || $TARGET == linux* ]]; then myconf+=( --host="$FFBUILD_TOOLCHAIN" diff --git a/scripts.d/25-openssl.sh b/scripts.d/25-openssl.sh index a3558da..c993e75 100755 --- a/scripts.d/25-openssl.sh +++ b/scripts.d/25-openssl.sh @@ -36,6 +36,11 @@ ffbuild_dockerbuild() { --cross-compile-prefix="$FFBUILD_CROSS_PREFIX" linux-x86_64 ) + elif [[ $TARGET == linuxarm64 ]]; then + myconf+=( + --cross-compile-prefix="$FFBUILD_CROSS_PREFIX" + linux-aarch64 + ) else echo "Unknown target" return -1 diff --git a/scripts.d/50-libvpx.sh b/scripts.d/50-libvpx.sh index b83b64b..4347e5d 100755 --- a/scripts.d/50-libvpx.sh +++ b/scripts.d/50-libvpx.sh @@ -32,11 +32,16 @@ ffbuild_dockerbuild() { --target=x86-win32-gcc ) export CROSS="$FFBUILD_CROSS_PREFIX" - elif [[ $TARGET == linux* ]]; then + elif [[ $TARGET == linux64 ]]; then myconf+=( --target=x86_64-linux-gcc ) export CROSS="$FFBUILD_CROSS_PREFIX" + elif [[ $TARGET == linuxarm64 ]]; then + myconf+=( + --target=arm64-linux-gcc + ) + export CROSS="$FFBUILD_CROSS_PREFIX" else echo "Unknown target" return -1 diff --git a/scripts.d/50-openh264.sh b/scripts.d/50-openh264.sh index 317c970..622483b 100755 --- a/scripts.d/50-openh264.sh +++ b/scripts.d/50-openh264.sh @@ -37,6 +37,11 @@ ffbuild_dockerbuild() { OS=linux ARCH=x86_64 ) + elif [[ $TARGET == linuxarm64 ]]; then + myconf+=( + OS=linux + ARCH=aarch64 + ) else echo "Unknown target" return -1 diff --git a/scripts.d/50-rav1e.sh b/scripts.d/50-rav1e.sh index 52ddb04..d865322 100755 --- a/scripts.d/50-rav1e.sh +++ b/scripts.d/50-rav1e.sh @@ -25,6 +25,12 @@ ffbuild_dockerbuild() { ) fi + # For some reason, RUSTFLAGS, CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER, + # and .cargo/config.toml can't work, so have to put a symbolic link + if [[ $TARGET == linuxarm64 ]]; then + ln -s /opt/ct-ng/bin/aarch64-ffbuild-linux-gnu-gcc /opt/ct-ng/bin/aarch64-linux-gnu-gcc + fi + cargo cinstall "${myconf[@]}" } diff --git a/scripts.d/50-vidstab.sh b/scripts.d/50-vidstab.sh index a52794c..62447fc 100755 --- a/scripts.d/50-vidstab.sh +++ b/scripts.d/50-vidstab.sh @@ -15,7 +15,12 @@ ffbuild_dockerbuild() { mkdir build && cd build - cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DUSE_OMP=ON .. + local disable_sse2="" + if [[ $TARGET == linuxarm64 ]]; then + disable_sse2=-DSSE2_FOUND=FALSE + fi + + cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DUSE_OMP=ON $disable_sse2 .. make -j$(nproc) make install