Skip to content

Commit

Permalink
Fix aarch64 build for windows and linux
Browse files Browse the repository at this point in the history
  • Loading branch information
HeavenVolkoff committed Oct 31, 2023
1 parent cacbfa4 commit 8f8682a
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/ffmpeg/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
out
out*
16 changes: 14 additions & 2 deletions .github/scripts/ffmpeg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,20 @@ export PKG_CONFIG_LIBDIR="${PREFIX}/lib/pkgconfig:${PREFIX}/share/pkgconfig"

case "$TARGET" in
*linux*)
export CFLAGS="-I${PREFIX}/include -pipe -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fstack-clash-protection -fvisibility=hidden"
export LDFLAGS="-L${PREFIX}/lib -pipe -fstack-protector-strong -fstack-clash-protection -Wl,-z,relro,-z,now"
export CFLAGS="-I${PREFIX}/include -pipe -D_FORTIFY_SOURCE=1 -fvisibility=hidden"
export LDFLAGS="-L${PREFIX}/lib -pipe -Wl,-z,relro,-z,now"

case "$TARGET" in
x86_64*)
export CFLAGS="${CFLAGS} -fstack-protector-strong -fstack-clash-protection"
export LDFLAGS="${LDFLAGS} -fstack-protector-strong -fstack-clash-protection"
;;
aarch64*)
# https://github.com/ziglang/zig/issues/17430#issuecomment-1752592338
export CFLAGS="${CFLAGS} -fno-stack-protector -fno-stack-check"
export LDFLAGS="${LDFLAGS} -fno-stack-protector -fno-stack-check"
esac

export CXXFLAGS="$CFLAGS"
export SHARED_FLAGS="${CFLAGS:-} -fno-semantic-interposition"
;;
Expand Down
5 changes: 4 additions & 1 deletion .github/scripts/ffmpeg/scripts/20-bzip2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
echo "Download bzip2..."
mkdir -p bzip2

curl_tar 'https://gitlab.com/bzip2/bzip2/-/archive/66c46b8c9436613fd81bc5d03f63a61933a4dcc3/bzip2-66c46b8c9436613fd81bc5d03f63a61933a4dcc3.tar.gz' bzip2 1
curl_tar 'https://gitlab.com/bzip2/bzip2/-/archive/66c46b8c/bzip2.tar.gz' bzip2 1

sed -i '/add_subdirectory(man)/d' bzip2/CMakeLists.txt

Expand All @@ -16,6 +16,9 @@ bak_src 'bzip2'
mkdir -p bzip2/build
cd bzip2/build

export CFLAGS="${CFLAGS:-} -DBZ_DEBUG=0"
export CXXFLAGS="${CXXFLAGS:-} -DBZ_DEBUG=0"

echo "Build bzip2..."
cmake \
-DUSE_OLD_SONAME=On \
Expand Down
3 changes: 1 addition & 2 deletions .github/scripts/ffmpeg/scripts/50-svt-av1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ case "$TARGET" in
aarch64*)
ENABLE_NASM=Off
# Patch to enable SSE in aarch64
curl -LSs 'https://raw.githubusercontent.com/HandBrake/HandBrake/621a6ff/contrib/svt-av1/A01-adds-neon-sse2neon-implementations-of-SVT-AV1_v15.patch' \
| patch -F5 -lp1 -d svt-av1 -t
curl -LSs 'https://gitlab.com/AOMediaCodec/SVT-AV1/-/merge_requests/2135.patch' | patch -F5 -lp1 -d svt-av1 -t
;;
esac

Expand Down
3 changes: 0 additions & 3 deletions .github/scripts/ffmpeg/scripts/50-zimg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ cd zimg

echo "Build zimg..."

export CFLAGS="${CFLAGS:-} -Oz"
export CXXFLAGS="${CFLAGS}"

./autogen.sh

./configure \
Expand Down
1 change: 0 additions & 1 deletion .github/scripts/ffmpeg/scripts/99-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ if ! ./configure \
--enable-optimizations \
--enable-postproc \
--enable-shared \
--enable-small \
--enable-swscale \
--enable-version3 \
--enable-vulkan \
Expand Down
14 changes: 13 additions & 1 deletion .github/scripts/ffmpeg/zig-cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -euo pipefail

case "$TARGET" in
case "${TARGET:?TARGET envvar is required to be defined}" in
*linux-gnu)
# Set the glibc minimum version
# This is the lowest we can go at the moment
Expand All @@ -19,6 +19,9 @@ case "$TARGET" in
*windows*)
LD='lld-link'
;;
# Mach-O (macOS) linker (ld64.lld) was dropped in favour of zig's internal linker
# https://github.com/ziglang/zig/commit/81bf05bf6c1249c39273b494d3e337d300b4ddd5
# https://github.com/ziglang/zig/commit/0e15205521b9a8c95db3c1714dffe3be1df5cda1
esac

case "$0" in
Expand Down Expand Up @@ -88,6 +91,12 @@ while [ "$#" -gt 0 ]; do
if [ "$lto" != '-fno-lto' ]; then
lto="$1"
fi
elif (case "$1" in -O* | --optimize*) exit 0 ;; *) exit 1 ;; esac) then
# Drop optmize flags, we force -Os below
# This also misteriosly fix an aarch64 compiler bug in clang 16
# https://github.com/llvm/llvm-project/issues/47432
# https://github.com/llvm/llvm-project/issues/66912
true
elif [ "$1" = '-xassembler' ] || [ "$1" = '--language=assembler' ]; then
# Zig behaves very oddly when passed the explicit assembler language option
# https://github.com/ziglang/zig/issues/10915
Expand Down Expand Up @@ -213,6 +222,9 @@ if [ "$help" -eq 0 ]; then
;;
esac

# Like -O2 with extra optimizations to reduce code size
c_argv+=(-Os)

# If a SDK is defined ensure it is set as sysroot if is not already set
if [ -z "$sysroot" ] && [ -d "${SDKROOT:-}" ]; then
c_argv+=("--sysroot=${SDKROOT}")
Expand Down
64 changes: 0 additions & 64 deletions .github/workflows/libheif-linux.yml

This file was deleted.

0 comments on commit 8f8682a

Please sign in to comment.