From 26231ecfcc80fd2c0621c776035edb12e5929fa8 Mon Sep 17 00:00:00 2001
From: Alexandre Janniaux <ajanni@videolabs.io>
Date: Mon, 31 May 2021 10:14:32 +0200
Subject: [PATCH] apple: build.sh: add bitcode flag to LDFLAGS too

The bitcode flag was already added to CFLAGS, but was only used when
creating a static build of libvlc, which doesn't involve linkage. When
creating shared plugins, the dylibs must be linked with the
-fembed-bitcode flag to gather the bitcode from the different objects.

In particular, bitcode is mandatory on tvOS, so this is mandatory when
building dynamic plugins and/or libvlc for tvOS.
---
 extras/package/apple/build.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/extras/package/apple/build.sh b/extras/package/apple/build.sh
index 1d030b3e63ca..6bd2762d160d 100755
--- a/extras/package/apple/build.sh
+++ b/extras/package/apple/build.sh
@@ -316,8 +316,10 @@ set_host_envvars()
 {
     # Flags to be used for C-like compilers (C, C++, Obj-C)
     local clike_flags="$VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH $1"
+    local bitcode_flag=""
     if [ "$VLC_USE_BITCODE" -gt "0" ]; then
         clike_flags+=" -fembed-bitcode"
+        bitcode_flag=" -fembed-bitcode"
     fi
 
     export CPPFLAGS="-arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH"
@@ -327,7 +329,7 @@ set_host_envvars()
     export OBJCFLAGS="$clike_flags"
 
     # Vanilla clang doesn't use VLC_DEPLOYMENT_TAGET_LDFLAGS but only the CFLAGS variant
-    export LDFLAGS="$VLC_DEPLOYMENT_TARGET_LDFLAG $VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH"
+    export LDFLAGS="$VLC_DEPLOYMENT_TARGET_LDFLAG $VLC_DEPLOYMENT_TARGET_CFLAG -arch $VLC_HOST_ARCH ${bitcode_flag}"
 }
 
 hostenv()
-- 
GitLab