From 585c0b02e1ba0d99c484a21189d0e335c4cf90b2 Mon Sep 17 00:00:00 2001
From: Alexandre Janniaux <ajanni@videolabs.io>
Date: Tue, 14 Sep 2021 21:58:49 +0200
Subject: [PATCH] apple: build.sh: add support for -fembed-bitcode-marker

---
 extras/package/apple/build.sh | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/extras/package/apple/build.sh b/extras/package/apple/build.sh
index 6bd2762d160d..b060aa138c34 100755
--- a/extras/package/apple/build.sh
+++ b/extras/package/apple/build.sh
@@ -98,6 +98,7 @@ VLC_REQUESTED_CORE_COUNT=0
 VLC_DISABLE_DEBUG=0
 # whether to compile with bitcode or not
 VLC_USE_BITCODE=0
+VLC_BITCODE_FLAG="-fembed-bitcode"
 # whether to build static or dynamic plugins
 VLC_BUILD_DYNAMIC=0
 
@@ -123,7 +124,8 @@ usage()
     echo " --arch=ARCH      Architecture to build for"
     echo "                   (i386|x86_64|armv7|arm64)"
     echo " --sdk=SDK        Name of the SDK to build with (see 'xcodebuild -showsdks')"
-    echo " --enable-bitcode Enable bitcode for compilation"
+    echo " --enable-bitcode        Enable bitcode for compilation, same as with =full"
+    echo " --enable-bitcode=marker Enable bitcode marker for compilation"
     echo " --disable-debug  Disable libvlc debug mode (for release)"
     echo " --verbose        Print verbose output and disable multi-core use"
     echo " --help           Print this help"
@@ -318,8 +320,8 @@ set_host_envvars()
     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"
+        clike_flags+=" $VLC_BITCODE_FLAG"
+        bitcode_flag=" $VLC_BTICODE_FLAG"
     fi
 
     export CPPFLAGS="-arch $VLC_HOST_ARCH -isysroot $VLC_APPLE_SDK_PATH"
@@ -364,6 +366,7 @@ write_config_mak()
     # 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"
     if [ "$VLC_USE_BITCODE" -gt "0" ]; then
+        # We use bitcode for contribs in every case, no dylib or executable built from them
         clike_flags+=" -fembed-bitcode"
     fi
 
@@ -453,8 +456,12 @@ do
         --disable-debug)
             VLC_DISABLE_DEBUG=1
             ;;
-        --enable-bitcode)
+        --enable-bitcode|--enable-bitcode=full)
+            VLC_USE_BITCODE=1
+            ;;
+        --enable-bitcode=marker)
             VLC_USE_BITCODE=1
+            VLC_BITCODE_FLAG="-fembed-bitcode-marker"
             ;;
         --arch=*)
             VLC_HOST_ARCH="${1#--arch=}"
-- 
GitLab