[vlc-commits] bank: enable static modules for mach-o binaries

Alexandre Janniaux git at videolan.org
Sat Apr 11 11:04:33 CEST 2020


vlc | branch: master | Alexandre Janniaux <ajanni at videolabs.io> | Thu Mar 12 16:35:40 2020 +0100| [51c464a85bc37c363fd3004b6aea87a69220679b] | committer: Alexandre Janniaux

bank: enable static modules for mach-o binaries

Static modules are available by overriding the vlc_static_modules
symbol in the executable. To avoid exposing this feature by forcing the
user to declare this symbol regardless of whether it was needed or not,
it was only defined on ELF binaries which supports the weak attributes
or when dynamic plugins are disabled as it becomes the only (thus
mandatory) way to define plugins.

Mach-O objects are also capable to define weak symbols, like defined
for the VLC_WEAK symbol in the vlc_common.h file so also allow this
mechanism when producing Mach-O objects.

It is particularly useful to ship battery-included LibVLC builds and
still allow external plugins in paths controlled by the application
using the library.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=51c464a85bc37c363fd3004b6aea87a69220679b
---

 src/Makefile.am    | 2 +-
 src/modules/bank.c | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 98de4fa48f..163e241ee1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -542,7 +542,7 @@ $(libvlccore_la_OBJECTS): libvlccore_objc.la
 libvlccore_objc_la_OBJCFLAGS = $(AM_OBJCFLAGS) -fobjc-arc
 libvlccore_objc_la_LDFLAGS = -static
 libvlccore_la_LIBADD += libvlccore_objc.la
-libvlccore_la_LDFLAGS +=  -Wl,-framework,Foundation -Xlinker -install_name -Xlinker @rpath/libvlccore.dylib
+libvlccore_la_LDFLAGS +=  -Wl,-framework,Foundation -Xlinker -install_name -Xlinker @rpath/libvlccore.dylib -Wl,-U,_vlc_static_modules
 endif
 
 libvlc_win32_rc.$(OBJEXT): libvlc_win32_rc.rc $(top_srcdir)/extras/package/win32/libvlc.dll.manifest
diff --git a/src/modules/bank.c b/src/modules/bank.c
index 36c4b30cdd..a880eea6e9 100644
--- a/src/modules/bank.c
+++ b/src/modules/bank.c
@@ -172,7 +172,12 @@ static vlc_plugin_t *module_InitStatic(vlc_plugin_cb entry)
     return lib;
 }
 
-#if defined(__ELF__) || !HAVE_DYNAMIC_PLUGINS
+/* With weak linking in __ELF__, there is no need to provide a definition
+ * of vlc_static_modules at build time and it will be evaluated to NULL if
+ * not provided at runtime. However, although __MACH__ implies the same runtime
+ * consequences for weak linking, it will still require the definition to exist
+ * at build time. To workaround this, we add -Wl,-U,vlc_static_modules. */
+#if defined(__ELF__) || defined(__MACH__) || !HAVE_DYNAMIC_PLUGINS
 VLC_WEAK
 extern vlc_plugin_cb vlc_static_modules[];
 



More information about the vlc-commits mailing list