meson: Build with -Wl,-z,nodelete to prevent unloading of dynamic libraries and plugins

GLib made the unfortunate decision to prevent libgobject from ever being
unloaded, which means that now any library which registers a static type
can't ever be unloaded either (and any library that depends on those,
ad nauseam).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/778>
This commit is contained in:
Zebediah Figura 2021-03-24 14:20:18 -05:00 committed by GStreamer Marge Bot
parent 9bb560e7ee
commit c4681ac428
10 changed files with 75 additions and 4 deletions

View file

@ -63,6 +63,12 @@ else
noseh_link_args = []
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
# Symbol visibility
if cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')

View file

@ -67,6 +67,12 @@ if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
# Symbol visibility
if cc.get_id() == 'msvc'
export_define = '__declspec(dllexport) extern'

View file

@ -140,6 +140,12 @@ if cc.get_id() == 'msvc'
add_project_arguments(msvc_args, language: ['c', 'cpp'])
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
# Symbol visibility
if cc.has_argument('-fvisibility=hidden')
add_project_arguments('-fvisibility=hidden', language: 'c')

View file

@ -49,6 +49,12 @@ else
noseh_link_args = []
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
cdata = configuration_data()
check_headers = [
# ['HAVE_DLFCN_H', 'dlfcn.h'],

View file

@ -102,6 +102,15 @@ if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
if cxx.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'cpp')
endif
# Symbol visibility
if cc.get_id() == 'msvc'
export_define = '__declspec(dllexport) extern'

View file

@ -95,6 +95,12 @@ if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
core_conf = configuration_data()
core_conf.set('ENABLE_NLS', 1)

View file

@ -18,6 +18,9 @@ gst_version_is_stable = gst_version_minor.is_even()
gst_version_is_dev = gst_version_minor.is_odd() and gst_version_micro < 90
have_cxx = add_languages('cpp', native: false, required: false)
if have_cxx
cxx = meson.get_compiler('cpp')
endif
glib_req = '>= 2.62.0'
orc_req = '>= 0.4.17'
@ -84,6 +87,18 @@ endif
if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
if have_cxx and cxx.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'cpp')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
if have_cxx and cxx.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'cpp')
endif
# Symbol visibility
if cc.has_argument('-fvisibility=hidden')
@ -234,10 +249,6 @@ warning_c_flags = [
'-Waggregate-return',
]
if have_cxx
cxx = meson.get_compiler('cpp')
endif
foreach extra_arg : warning_flags
if cc.has_argument (extra_arg)
add_project_arguments([extra_arg], language: 'c')

View file

@ -89,6 +89,15 @@ if have_cxx and cxx.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'cpp')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
if have_cxx and cxx.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'cpp')
endif
cdata = configuration_data()
cdata.set('ENABLE_NLS', 1)

View file

@ -42,6 +42,12 @@ if cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
# Symbol visibility
if cc.get_id() == 'msvc'
export_define = '__declspec(dllexport) extern'

View file

@ -74,6 +74,12 @@ elif cc.has_link_argument('-Wl,-Bsymbolic-functions')
add_project_link_arguments('-Wl,-Bsymbolic-functions', language : 'c')
endif
# glib doesn't support unloading, which means that unloading and reloading
# any library that registers static types will fail
if cc.has_link_argument('-Wl,-z,nodelete')
add_project_link_arguments('-Wl,-z,nodelete', language: 'c')
endif
# Symbol visibility
have_visibility_hidden = false
if cc.get_id() == 'msvc'