[vlc-commits] [Git][videolan/vlc][master] meson: only export the entry points from plugins
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Oct 11 06:23:48 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
8d766446 by Wassim Lalaoui at 2026-10-11T06:09:06+00:00
meson: only export the entry points from plugins
A plugin is loaded with dlopen() and libvlccore only looks up its entry
points by name, so nothing else should be exported. The autotools build
enforces this through libtool's -export-symbols-regex ^vlc_entry, which
libtool translates to the mechanism of each platform. The meson build had
no equivalent and exported everything, including the symbols of the
static libraries linked into the plugins.
Besides the larger dynamic symbol tables, exported symbols are
preemptible, so the linker cannot bind them locally. Static contrib
libraries holding non-PIC objects then fail to link:
libx265.a(cpu-a.asm.o): relocation R_X86_64_PC32 against symbol
`x265_intel_cpu_indicator_init' can not be used when making a shared
object; recompile with -fPIC
meson has no equivalent of -export-symbols-regex, so use the first export
mechanism accepted by the linker, with the same vlc_entry* pattern:
- a version script (modules/vlc_plugin.map): GNU ld, gold, lld, mold,
- -exported_symbol, which takes wildcards too: ld64, ld64.lld.
On Windows and OS/2, the entry points are already the only exports, since
they are declared with __declspec(dllexport).
- - - - -
2 changed files:
- modules/meson.build
- + modules/vlc_plugin.map
Changes:
=====================================
modules/meson.build
=====================================
@@ -424,6 +424,26 @@ endif
# array is then iterated over and a library is defined for each
# entry with the needed build definition for a VLC plugin.
#
+
+# A plugin is loaded with dlopen() and libvlccore only looks up its entry
+# points by name, so nothing else may be exported. The autotools build gets
+# this from libtool's -export-symbols-regex ^vlc_entry; here the first export
+# mechanism accepted by the linker is used:
+# - a version script (GNU ld, gold, lld, mold),
+# - -exported_symbol, which takes wildcards too (ld64, ld64.lld).
+# On Windows and OS/2, the entry points are declared with __declspec(dllexport)
+# (DLL_SYMBOL in vlc_plugin.h), which already disables the automatic export of
+# every other symbol.
+vlc_plugin_link_args = []
+vlc_plugin_link_depends = []
+vlc_plugin_version_script = meson.current_source_dir() / 'vlc_plugin.map'
+if cc.has_link_argument('-Wl,--version-script=' + vlc_plugin_version_script)
+ vlc_plugin_link_args += '-Wl,--version-script=' + vlc_plugin_version_script
+ vlc_plugin_link_depends += files('vlc_plugin.map')
+elif cc.has_link_argument('-Wl,-exported_symbol,_vlc_entry*')
+ vlc_plugin_link_args += '-Wl,-exported_symbol,_vlc_entry*'
+endif
+
vlc_plugins_targets = {}
vlc_plugins_targets_array = []
vlc_plugins_manifest = {}
@@ -498,8 +518,8 @@ foreach module : vlc_modules
module['name'] + '_plugin',
module['sources'] + win_extra_sources,
link_with: [module.get('link_with', []), vlc_libcompat],
- link_args: [module.get('link_args', []), symbolic_linkargs, gc_sections_linkargs],
- link_depends: module.get('link_depends', []),
+ link_args: [module.get('link_args', []), symbolic_linkargs, gc_sections_linkargs, vlc_plugin_link_args],
+ link_depends: [module.get('link_depends', []), vlc_plugin_link_depends],
include_directories: [module.get('include_directories', []), vlc_include_dirs],
dependencies: [module.get('dependencies', []), libvlccore_dep],
c_args: [module.get('c_args', []), common_args],
@@ -604,8 +624,8 @@ if get_option('rust').enabled()
# `module_cargo` is an archive file everything is exported so nothing is really.
link_whole: module_cargo,
link_with: module.get('link_with', []),
- link_args: [module.get('link_args', []), rust_common_link_args],
- link_depends: module.get('link_depends', []),
+ link_args: [module.get('link_args', []), rust_common_link_args, vlc_plugin_link_args],
+ link_depends: [module.get('link_depends', []), vlc_plugin_link_depends],
dependencies: [module.get('dependencies', []), libvlccore_dep],
build_by_default: true,
)
=====================================
modules/vlc_plugin.map
=====================================
@@ -0,0 +1,4 @@
+{
+ global: vlc_entry*;
+ local: *;
+};
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8d7664469038be3cb06cf3c0464d348a76a214df
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/8d7664469038be3cb06cf3c0464d348a76a214df
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list