build: new option to build plugins within the daemon binary
Instead of creating libmm-plugin* and libmm-shared* libraries that are dlopen()-ed on runtime, allow incorporating all plugins into the daemon binary itself. This makes the startup of the daemon much faster and also avoids issues with builds that require linker namespace isolation. Fixes https://gitlab.freedesktop.org/mobile-broadband/ModemManager/-/issues/674
This commit is contained in:
committed by
Aleksander Morgado
parent
1dd70be4c8
commit
1c4da332ee
+35
-17
@@ -1,8 +1,10 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2021 Iñigo Martinez <inigomartinez@gmail.com>
|
||||
|
||||
symbol_map = plugins_dir / 'symbol.map'
|
||||
ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
|
||||
if not enable_builtin_plugins
|
||||
symbol_map = plugins_dir / 'symbol.map'
|
||||
ldflags = cc.get_supported_link_arguments('-Wl,--version-script,@0@'.format(symbol_map))
|
||||
endif
|
||||
|
||||
# common service test support
|
||||
plugins_common_test_dep = []
|
||||
@@ -36,7 +38,6 @@ if enable_tests
|
||||
endif
|
||||
|
||||
# plugins
|
||||
plugins_inc = include_directories('.')
|
||||
plugins = {}
|
||||
plugins_data = []
|
||||
plugins_udev_rules = []
|
||||
@@ -958,6 +959,13 @@ if plugins_options['zte']
|
||||
plugins_udev_rules += files('zte/77-mm-zte-port-types.rules')
|
||||
endif
|
||||
|
||||
builtin_sources = []
|
||||
builtin_plugins = []
|
||||
|
||||
if enable_builtin_plugins
|
||||
builtin_sources += files('mm-builtin-plugins.c')
|
||||
endif
|
||||
|
||||
foreach plugin_name, plugin_data: plugins
|
||||
libpluginhelpers = []
|
||||
if plugin_data.has_key('helper')
|
||||
@@ -969,21 +977,31 @@ foreach plugin_name, plugin_data: plugins
|
||||
endif
|
||||
|
||||
module_args = plugin_data['module']
|
||||
if plugin_data['plugin']
|
||||
module_args += {
|
||||
'link_args': ldflags,
|
||||
'link_depends': symbol_map,
|
||||
}
|
||||
endif
|
||||
if not enable_builtin_plugins
|
||||
if plugin_data['plugin']
|
||||
module_args += {
|
||||
'link_args': ldflags,
|
||||
'link_depends': symbol_map,
|
||||
}
|
||||
endif
|
||||
|
||||
shared_module(
|
||||
'mm-' + plugin_name,
|
||||
dependencies: plugins_deps,
|
||||
link_with: libpluginhelpers,
|
||||
kwargs: module_args,
|
||||
install: true,
|
||||
install_dir: mm_pkglibdir,
|
||||
)
|
||||
shared_module(
|
||||
'mm-' + plugin_name,
|
||||
dependencies: plugins_deps,
|
||||
link_with: libpluginhelpers,
|
||||
kwargs: module_args,
|
||||
install: true,
|
||||
install_dir: mm_pkglibdir,
|
||||
)
|
||||
else
|
||||
libplugin = static_library(
|
||||
'mm-' + plugin_name,
|
||||
dependencies: plugins_deps,
|
||||
link_with: libpluginhelpers,
|
||||
kwargs: module_args,
|
||||
)
|
||||
builtin_plugins += libplugin
|
||||
endif
|
||||
|
||||
if enable_tests
|
||||
if plugin_data.has_key('test')
|
||||
|
||||
@@ -0,0 +1,273 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2022 Google Inc.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "mm-plugin.h"
|
||||
#include "mm-builtin-plugins.h"
|
||||
|
||||
#if defined ENABLE_PLUGIN_ALTAIR_LTE
|
||||
MMPlugin *mm_plugin_create_altair_lte (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_ANYDATA
|
||||
MMPlugin *mm_plugin_create_anydata (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_BROADMOBI
|
||||
MMPlugin *mm_plugin_create_broadmobi (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_CINTERION
|
||||
MMPlugin *mm_plugin_create_cinterion (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_DELL
|
||||
MMPlugin *mm_plugin_create_dell (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_DLINK
|
||||
MMPlugin *mm_plugin_create_dlink (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_FIBOCOM
|
||||
MMPlugin *mm_plugin_create_fibocom (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_FOXCONN
|
||||
MMPlugin *mm_plugin_create_foxconn (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_GENERIC
|
||||
MMPlugin *mm_plugin_create_generic (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_GOSUNCN
|
||||
MMPlugin *mm_plugin_create_gosuncn (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_HAIER
|
||||
MMPlugin *mm_plugin_create_haier (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_HUAWEI
|
||||
MMPlugin *mm_plugin_create_huawei (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_INTEL
|
||||
MMPlugin *mm_plugin_create_intel (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_IRIDIUM
|
||||
MMPlugin *mm_plugin_create_iridium (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_LINKTOP
|
||||
MMPlugin *mm_plugin_create_linktop (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_LONGCHEER
|
||||
MMPlugin *mm_plugin_create_longcheer (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MBM
|
||||
MMPlugin *mm_plugin_create_mbm (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MOTOROLA
|
||||
MMPlugin *mm_plugin_create_motorola (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MTK
|
||||
MMPlugin *mm_plugin_create_mtk (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOKIA
|
||||
MMPlugin *mm_plugin_create_nokia (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOKIA_ICERA
|
||||
MMPlugin *mm_plugin_create_nokia_icera (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOVATEL
|
||||
MMPlugin *mm_plugin_create_novatel (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOVATEL_LTE
|
||||
MMPlugin *mm_plugin_create_novatel_lte (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_OPTION
|
||||
MMPlugin *mm_plugin_create_option (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_OPTION_HSO
|
||||
MMPlugin *mm_plugin_create_hso (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_PANTECH
|
||||
MMPlugin *mm_plugin_create_pantech (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_QCOM_SOC
|
||||
MMPlugin *mm_plugin_create_qcom_soc (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_QUECTEL
|
||||
MMPlugin *mm_plugin_create_quectel (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SAMSUNG
|
||||
MMPlugin *mm_plugin_create_samsung (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIERRA
|
||||
MMPlugin *mm_plugin_create_sierra (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIERRA_LEGACY
|
||||
MMPlugin *mm_plugin_create_sierra_legacy (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIMTECH
|
||||
MMPlugin *mm_plugin_create_simtech (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_TELIT
|
||||
MMPlugin *mm_plugin_create_telit (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_THURAYA
|
||||
MMPlugin *mm_plugin_create_thuraya (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_TPLINK
|
||||
MMPlugin *mm_plugin_create_tplink (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_UBLOX
|
||||
MMPlugin *mm_plugin_create_ublox (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_VIA
|
||||
MMPlugin *mm_plugin_create_via (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_WAVECOM
|
||||
MMPlugin *mm_plugin_create_wavecom (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_X22X
|
||||
MMPlugin *mm_plugin_create_x22x (void);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_ZTE
|
||||
MMPlugin *mm_plugin_create_zte (void);
|
||||
#endif
|
||||
|
||||
GList *
|
||||
mm_builtin_plugins_load (void)
|
||||
{
|
||||
GList *builtin_plugins = NULL;
|
||||
|
||||
#define PREPEND_PLUGIN(my_plugin) \
|
||||
builtin_plugins = g_list_prepend (builtin_plugins, mm_plugin_create_##my_plugin ())
|
||||
|
||||
#if defined ENABLE_PLUGIN_ALTAIR_LTE
|
||||
PREPEND_PLUGIN (altair_lte);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_ANYDATA
|
||||
PREPEND_PLUGIN (anydata);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_BROADMOBI
|
||||
PREPEND_PLUGIN (broadmobi);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_CINTERION
|
||||
PREPEND_PLUGIN (cinterion);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_DELL
|
||||
PREPEND_PLUGIN (dell);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_DLINK
|
||||
PREPEND_PLUGIN (dlink);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_FIBOCOM
|
||||
PREPEND_PLUGIN (fibocom);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_FOXCONN
|
||||
PREPEND_PLUGIN (foxconn);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_GENERIC
|
||||
PREPEND_PLUGIN (generic);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_GOSUNCN
|
||||
PREPEND_PLUGIN (gosuncn);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_HAIER
|
||||
PREPEND_PLUGIN (haier);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_HUAWEI
|
||||
PREPEND_PLUGIN (huawei);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_INTEL
|
||||
PREPEND_PLUGIN (intel);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_IRIDIUM
|
||||
PREPEND_PLUGIN (iridium);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_LINKTOP
|
||||
PREPEND_PLUGIN (linktop);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_LONGCHEER
|
||||
PREPEND_PLUGIN (longcheer);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MBM
|
||||
PREPEND_PLUGIN (mbm);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MOTOROLA
|
||||
PREPEND_PLUGIN (motorola);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_MTK
|
||||
PREPEND_PLUGIN (mtk);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOKIA
|
||||
PREPEND_PLUGIN (nokia);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOKIA_ICERA
|
||||
PREPEND_PLUGIN (nokia_icera);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOVATEL
|
||||
PREPEND_PLUGIN (novatel);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_NOVATEL_LTE
|
||||
PREPEND_PLUGIN (novatel_lte);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_OPTION
|
||||
PREPEND_PLUGIN (option);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_OPTION_HSO
|
||||
PREPEND_PLUGIN (hso);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_PANTECH
|
||||
PREPEND_PLUGIN (pantech);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_QCOM_SOC
|
||||
PREPEND_PLUGIN (qcom_soc);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_QUECTEL
|
||||
PREPEND_PLUGIN (quectel);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SAMSUNG
|
||||
PREPEND_PLUGIN (samsung);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIERRA
|
||||
PREPEND_PLUGIN (sierra);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIERRA_LEGACY
|
||||
PREPEND_PLUGIN (sierra_legacy);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_SIMTECH
|
||||
PREPEND_PLUGIN (simtech);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_TELIT
|
||||
PREPEND_PLUGIN (telit);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_THURAYA
|
||||
PREPEND_PLUGIN (thuraya);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_TPLINK
|
||||
PREPEND_PLUGIN (tplink);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_UBLOX
|
||||
PREPEND_PLUGIN (ublox);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_VIA
|
||||
PREPEND_PLUGIN (via);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_WAVECOM
|
||||
PREPEND_PLUGIN (wavecom);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_X22X
|
||||
PREPEND_PLUGIN (x22x);
|
||||
#endif
|
||||
#if defined ENABLE_PLUGIN_ZTE
|
||||
PREPEND_PLUGIN (zte);
|
||||
#endif
|
||||
#undef PREPEND_PLUGIN
|
||||
return builtin_plugins;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2022 Google Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_BUILTIN_PLUGINS_H
|
||||
#define MM_BUILTIN_PLUGINS_H
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
|
||||
#if !defined WITH_BUILTIN_PLUGINS
|
||||
# error Build with builtin plugins was not enabled
|
||||
#endif
|
||||
|
||||
GList *mm_builtin_plugins_load (void);
|
||||
|
||||
#endif /* MM_BUILTIN_PLUGINS_H */
|
||||
@@ -26,20 +26,28 @@
|
||||
|
||||
#include "mm-plugin.h"
|
||||
|
||||
#define MM_PLUGIN_NAMED_CREATOR_SCOPE static
|
||||
#if defined (G_HAVE_GNUC_VISIBILITY)
|
||||
# define MM_VISIBILITY __attribute__((visibility("protected")))
|
||||
#else
|
||||
# define MM_VISIBILITY
|
||||
#endif
|
||||
|
||||
#define MM_PLUGIN_CREATOR(my_plugin) \
|
||||
#if defined WITH_BUILTIN_PLUGINS
|
||||
# define MM_PLUGIN_VERSION
|
||||
# define MM_PLUGIN_NAMED_CREATOR_SCOPE
|
||||
# define MM_PLUGIN_CREATOR(unused)
|
||||
#else
|
||||
# define MM_PLUGIN_VERSION \
|
||||
MM_VISIBILITY int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; \
|
||||
MM_VISIBILITY int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
|
||||
# define MM_PLUGIN_NAMED_CREATOR_SCOPE static
|
||||
# define MM_PLUGIN_CREATOR(my_plugin) \
|
||||
G_MODULE_EXPORT MMPlugin *mm_plugin_create (void); \
|
||||
G_MODULE_EXPORT MMPlugin * \
|
||||
mm_plugin_create (void) \
|
||||
{ \
|
||||
return mm_plugin_create_##my_plugin (); \
|
||||
}
|
||||
|
||||
#if defined (G_HAVE_GNUC_VISIBILITY)
|
||||
# define MM_VISIBILITY __attribute__((visibility("protected")))
|
||||
#else
|
||||
# define MM_VISIBILITY
|
||||
#endif
|
||||
|
||||
#define MM_DEFINE_PLUGIN(MY_PLUGIN, my_plugin, MyPlugin) \
|
||||
@@ -49,8 +57,7 @@
|
||||
}; \
|
||||
G_DEFINE_TYPE (MMPlugin##MyPlugin, mm_plugin_##my_plugin, MM_TYPE_PLUGIN) \
|
||||
\
|
||||
MM_VISIBILITY int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION; \
|
||||
MM_VISIBILITY int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION; \
|
||||
MM_PLUGIN_VERSION \
|
||||
\
|
||||
MM_PLUGIN_NAMED_CREATOR_SCOPE MMPlugin *mm_plugin_create_##my_plugin (void); \
|
||||
MM_PLUGIN_CREATOR(my_plugin)
|
||||
|
||||
@@ -33,9 +33,13 @@
|
||||
#define MM_VISIBILITY
|
||||
#endif
|
||||
|
||||
#define MM_DEFINE_SHARED(MyShared) \
|
||||
#if defined WITH_BUILTIN_PLUGINS
|
||||
# define MM_DEFINE_SHARED(unused)
|
||||
#else
|
||||
# define MM_DEFINE_SHARED(MyShared) \
|
||||
MM_VISIBILITY int mm_shared_major_version = MM_SHARED_MAJOR_VERSION; \
|
||||
MM_VISIBILITY int mm_shared_minor_version = MM_SHARED_MINOR_VERSION; \
|
||||
MM_VISIBILITY const char *mm_shared_name = #MyShared;
|
||||
#endif
|
||||
|
||||
#endif /* MM_SHARED_COMMON_H */
|
||||
|
||||
Reference in New Issue
Block a user