build/meson: fix linking of core plugins to not include static helper libraries

We have many static helper libraries, like libnm-glib-aux or libnm-core.
These can be statically linked in any end-binary as internal API. However, they
must only be linked once.

Also, we have various plugins (device, settings, ppp, wwan) which are
dlopened by NetworkManager. They should use the symbols from
NetworkManager core. It is important that they do not link with the
static libraries already, because also NetworkManager core links with
it, so these symbols will be duplicate.

As the symbols are internal, you might think that it is not a real
problem to duplicate them. However, there are also global variables,
like the hash tables for NMRefStr or the seed for NMHash. These global
variables must be only be used once, and hence also these symbols must
no be duplicated.

Fix that by adding a new dependency that is for the core plugins. This
dependency only has "include_directories" but not "link_with".
This commit is contained in:
Thomas Haller 2021-01-28 08:39:19 +01:00
parent 98ae351134
commit b98ec9bc58
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
10 changed files with 27 additions and 12 deletions

View file

@ -6,7 +6,7 @@ libnm_device_plugin_adsl = shared_module(
'nm-atm-manager.c',
'nm-device-adsl.c',
),
dependencies: core_default_dep,
dependencies: core_plugin_dep,
c_args: daemon_c_flags,
link_args: ldflags_linker_script_devices,
link_depends: linker_script_devices,

View file

@ -22,7 +22,7 @@ libnm_device_plugin_bluetooth_static_dep = declare_dependency(
libnm_device_plugin_bluetooth = shared_module(
'nm-device-plugin-bluetooth',
dependencies: [
core_default_dep,
core_plugin_dep,
libnm_wwan_dep,
bluez5_dep,
libnm_device_plugin_bluetooth_static_dep,

View file

@ -10,7 +10,7 @@ libnm_device_plugin_ovs = shared_module(
'nm-ovs-factory.c',
),
dependencies: [
core_default_dep,
core_plugin_dep,
jansson_dep,
],
c_args: daemon_c_flags,

View file

@ -7,7 +7,7 @@ libnm_device_plugin_team = shared_module(
'nm-team-factory.c',
),
dependencies: [
core_default_dep,
core_plugin_dep,
jansson_dep,
libteamdctl_dep,
],

View file

@ -19,7 +19,9 @@ libnm_device_plugin_wifi_static = static_library(
'nm-wifi-p2p-peer.c',
'nm-wifi-utils.c',
) + iwd_sources,
dependencies: core_default_dep,
dependencies: [
core_plugin_dep,
],
c_args: daemon_c_flags,
)
@ -33,8 +35,8 @@ libnm_device_plugin_wifi = shared_module(
'nm-wifi-factory.c',
),
dependencies: [
core_default_dep,
libnm_device_plugin_wifi_static_dep,
core_plugin_dep,
libnm_device_plugin_wifi_static_dep
],
c_args: daemon_c_flags,
link_args: ldflags_linker_script_devices,

View file

@ -13,7 +13,7 @@ libnm_wwan = shared_module(
'nm-modem-manager.c',
) + (enable_ofono ? files('nm-modem-ofono.c') : files()),
dependencies: [
core_default_dep,
core_plugin_dep,
libsystemd_dep,
mm_glib_dep,
],
@ -47,7 +47,7 @@ libnm_device_plugin_wwan = shared_module(
'nm-wwan-factory.c',
),
dependencies: [
core_default_dep,
core_plugin_dep,
libsystemd_dep,
mm_glib_dep,
],

View file

@ -2,6 +2,19 @@
src_inc = include_directories('.')
core_plugin_dep = declare_dependency(
sources: libnm_core_enum_sources[1],
include_directories: [
src_inc,
top_inc,
shared_inc,
libnm_core_inc,
],
dependencies: [
glib_dep,
],
)
core_default_dep = declare_dependency(
sources: libnm_core_enum_sources[1],
include_directories: src_inc,

View file

@ -20,7 +20,7 @@ core_plugins += shared_module(
sources: [
'nm-ppp-manager.c',
],
dependencies: core_default_dep,
dependencies: core_plugin_dep,
c_args: daemon_c_flags,
link_args: '-Wl,--version-script,@0@'.format(linker_script),
link_depends: linker_script,

View file

@ -37,7 +37,7 @@ libnm_settings_plugin_ifcfg_rh = shared_module(
'nms-ifcfg-rh-storage.c',
'nms-ifcfg-rh-plugin.c',
),
dependencies: core_default_dep,
dependencies: core_plugin_dep,
c_args: daemon_c_flags,
link_with: libnms_ifcfg_rh_core,
link_args: ldflags_linker_script_settings,

View file

@ -13,7 +13,7 @@ libnms_ifupdown_core = static_library(
libnm_settings_plugin_ifupdown = shared_module(
'nm-settings-plugin-ifupdown',
sources: 'nms-ifupdown-plugin.c',
dependencies: core_default_dep,
dependencies: core_plugin_dep,
c_args: daemon_c_flags,
link_with: libnms_ifupdown_core,
link_args: ldflags_linker_script_settings,