[vlc-devel] [PATCH] apple: add support for partial linking

Alexandre Janniaux ajanni at videolabs.io
Tue Feb 2 09:05:33 UTC 2021


Each plugin built as archive library will have its object partially
linked before getting ar-chived. The work here is also partial since
dependencies are not partially-linked into the plugin too. In the
future, it will help prevent clashing of symbols between plugins and
reduce bloats in the final library archive on the current iOS static
build.

Note that this trades optimization window for less object bloating and
the guarantee that each plugin is only made of one object. Next step is
to be able to include the contribs and properly localize the symbols
that are not meant to be exposed for the VLC plugin ABI.
---
 extras/package/apple/ar.sh    | 12 ++++++++++++
 extras/package/apple/build.sh | 10 +++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100755 extras/package/apple/ar.sh

diff --git a/extras/package/apple/ar.sh b/extras/package/apple/ar.sh
new file mode 100755
index 0000000000..dc804305d9
--- /dev/null
+++ b/extras/package/apple/ar.sh
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+set -eu
+OPTIONS=$1; shift
+TARGET=$1; shift
+
+if echo "${TARGET}" | grep "_plugin.a\$"; then
+    ${CC} ${CFLAGS} ${LDFLAGS} -r -o ${TARGET}.partial.o $@
+    ${AR} ${OPTIONS} ${TARGET} ${TARGET}.partial.o
+else
+    ${AR} ${OPTIONS} ${TARGET} $@
+fi
diff --git a/extras/package/apple/build.sh b/extras/package/apple/build.sh
index 1868c8f1f4..ba9728d456 100755
--- a/extras/package/apple/build.sh
+++ b/extras/package/apple/build.sh
@@ -324,7 +324,7 @@ hostenv()
     CXX="${VLC_HOST_CXX}" \
     OBJC="${VLC_HOST_OBJC}" \
     LD="${VLC_HOST_LD}" \
-    AR="${VLC_HOST_AR}" \
+    AR="${VLC_BUILD_DIR}/build/ar.sh" \
     STRIP="${VLC_HOST_STRIP}" \
     RANLIB="${VLC_HOST_RANLIB}" \
     NM="${VLC_HOST_NM}" \
@@ -674,6 +674,14 @@ fi
 mkdir -p "${VLC_BUILD_DIR}/build"
 cd "${VLC_BUILD_DIR}/build" || abort_err "Failed cd to VLC build dir"
 
+echo "#!/usr/bin/env sh" > ar.sh
+echo "export CFLAGS=\"${CFLAGS}\"" >> ar.sh
+echo "export LDFLAGS=\"${LDFLAGS}\"" >> ar.sh
+echo "export CC=\"${VLC_HOST_CC}\"" >> ar.sh
+echo "export AR=\"${VLC_HOST_AR}\"" >> ar.sh
+echo "${VLC_SCRIPT_DIR}/ar.sh \$@" >> ar.sh
+chmod +x ar.sh
+
 # Create VLC install dir if it does not already exist
 mkdir -p "$VLC_INSTALL_DIR"
 
-- 
2.30.0



More information about the vlc-devel mailing list