Subject: [PATCH BlueZ v4 0/8] Remove support for external plugins

Hello everyone,

With v4 we have moved from pre-processor to compilation checking for the
external plugins support.

Namely, as we build without one the dead-code elimination will discard
all the relevant code. Ultimately this means we compile check both paths
in order to catch mistakes. Thanks to Luiz for the suggestion.

Link to the previous revision can be found below.

Thanks
Emil

- Link to v3: https://lore.kernel.org/r/[email protected]

---
Emil Velikov (8):
configure, README: introduce --enable-external-plugins
obexd: factor out external plugin support
bluetoothd: remove external-dummy plugin
bluetoothd: convert external sixaxis plugin to builtin
bluetoothd: factor out external plugin support
bluetoothd: don't export internal API
bluetoothd: change plugin loading alike obexd
android: export only (android) entrypoint from the modules

Makefile.am | 17 ++----
Makefile.obexd | 2 +
Makefile.plugins | 8 ++-
README | 13 +++++
android/Makefile.am | 3 ++
android/hal-audio.c | 1 +
android/hal-bluetooth.c | 1 +
android/hal-sco.c | 1 +
configure.ac | 10 ++++
obexd/src/obexd.h | 2 +-
obexd/src/plugin.c | 89 ++++++++++++++++++++-----------
obexd/src/plugin.h | 4 ++
plugins/external-dummy.c | 28 ----------
src/btd.h | 2 +-
src/plugin.c | 135 ++++++++++++++++++++++++++++-------------------
src/plugin.h | 4 ++
16 files changed, 188 insertions(+), 132 deletions(-)
---
base-commit: 0de32f67f685b95c35a5c2f1206081af89bd88b6
change-id: 20240116-rm-ext-plugins-ba0b852a492b

Best regards,
--
Emil Velikov <[email protected]>



Subject: [PATCH BlueZ v4 8/8] android: export only (android) entrypoint from the modules

From: Emil Velikov <[email protected]>

The android specific modules, have a designated HMI entrypoint. Hide
everything else with -fvisibility=hidden.
---
android/Makefile.am | 3 +++
android/hal-audio.c | 1 +
android/hal-bluetooth.c | 1 +
android/hal-sco.c | 1 +
4 files changed, 6 insertions(+)

diff --git a/android/Makefile.am b/android/Makefile.am
index 309910147..e3756e89c 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -96,6 +96,7 @@ android_bluetooth_default_la_SOURCES = android/hal.h android/hal-bluetooth.c \
android/hal-log.h \
android/hal-ipc.h android/hal-ipc.c \
android/hal-utils.h android/hal-utils.c
+android_bluetooth_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
android_bluetooth_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android
android_bluetooth_default_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
-no-undefined
@@ -195,6 +196,7 @@ android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \
android/hardware/audio_effect.h \
android/hardware/hardware.h \
android/system/audio.h
+android_audio_a2dp_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
android_audio_a2dp_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android \
$(SBC_CFLAGS)
android_audio_a2dp_default_la_LIBADD = $(SBC_LIBS) -lrt
@@ -212,6 +214,7 @@ android_audio_sco_default_la_SOURCES = android/hal-log.h \
android/audio_utils/resampler.c \
android/audio_utils/resampler.h \
android/system/audio.h
+android_audio_sco_default_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
android_audio_sco_default_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/android
android_audio_sco_default_la_LIBADD = $(SPEEXDSP_LIBS) -lrt
android_audio_sco_default_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
diff --git a/android/hal-audio.c b/android/hal-audio.c
index d37d6098c..f3d9b40a6 100644
--- a/android/hal-audio.c
+++ b/android/hal-audio.c
@@ -1618,6 +1618,7 @@ static struct hw_module_methods_t hal_module_methods = {
.open = audio_open,
};

+__attribute__ ((visibility("default")))
struct audio_module HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index d4442e620..7d1e5ac63 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -1117,6 +1117,7 @@ static struct hw_module_methods_t bluetooth_module_methods = {
.open = open_bluetooth,
};

+__attribute__ ((visibility("default")))
struct hw_module_t HAL_MODULE_INFO_SYM = {
.tag = HARDWARE_MODULE_TAG,
.version_major = 1,
diff --git a/android/hal-sco.c b/android/hal-sco.c
index d7c08a68b..3d66ad357 100644
--- a/android/hal-sco.c
+++ b/android/hal-sco.c
@@ -1507,6 +1507,7 @@ static struct hw_module_methods_t hal_module_methods = {
.open = sco_open,
};

+__attribute__ ((visibility("default")))
struct audio_module HAL_MODULE_INFO_SYM = {
.common = {
.tag = HARDWARE_MODULE_TAG,

--
2.43.0


Subject: [PATCH BlueZ v4 6/8] bluetoothd: don't export internal API

From: Emil Velikov <[email protected]>

... when building without external plugins.
---
Makefile.am | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 2d5650ced..2b1b9acdf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -289,7 +289,6 @@ pkglibexec_PROGRAMS += src/bluetoothd

src_bluetoothd_SOURCES = $(builtin_sources) \
$(attrib_sources) $(btio_sources) \
- src/bluetooth.ver \
src/main.c src/log.h src/log.c \
src/backtrace.h src/backtrace.c \
src/rfkill.c src/btd.h src/sdpd.h \
@@ -321,8 +320,12 @@ src_bluetoothd_LDADD = lib/libbluetooth-internal.la \
src/libshared-glib.la \
$(BACKTRACE_LIBS) $(GLIB_LIBS) $(DBUS_LIBS) -ldl -lrt \
$(builtin_ldadd)
+
+if EXTERNAL_PLUGINS
+src_bluetoothd_SOURCES += src/bluetooth.ver
src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
-Wl,--version-script=$(srcdir)/src/bluetooth.ver
+endif

src_bluetoothd_CPPFLAGS = $(AM_CPPFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
-DPLUGINDIR=\""$(build_plugindir)"\" \

--
2.43.0


Subject: [PATCH BlueZ v4 4/8] bluetoothd: convert external sixaxis plugin to builtin

From: Emil Velikov <[email protected]>

Convert the only known external plugin to built-in. It's a tiny 20K
binary that distros ship a separate package for.

Make it a builtin, which allows distros to drop the separate package, it
also enables us to compile out support for external modules - both in
terms of extra code and hide the internal bluetoothd API.

This means that libudev.so is pulled in, which is fine since its ABI has
been stable for over a decade.
---
Makefile.plugins | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/Makefile.plugins b/Makefile.plugins
index 5880ed0df..7cf66fd59 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -110,11 +110,9 @@ builtin_modules += battery
builtin_sources += profiles/battery/battery.c

if SIXAXIS
-plugin_LTLIBRARIES += plugins/sixaxis.la
-plugins_sixaxis_la_SOURCES = plugins/sixaxis.c
-plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version
-plugins_sixaxis_la_LIBADD = $(UDEV_LIBS)
-plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
+builtin_modules += sixaxis
+builtin_sources += plugins/sixaxis.c
+builtin_ldadd += $(UDEV_LIBS)
endif

if BAP

--
2.43.0


2024-01-29 15:38:57

by Paul Menzel

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 8/8] android: export only (android) entrypoint from the modules

Dear Emil,


Thank you for your patches. One small nit.


Am 29.01.24 um 15:44 schrieb Emil Velikov via B4 Relay:
> From: Emil Velikov <[email protected]>
>
> The android specific modules, have a designated HMI entrypoint. Hide

The comma seems superfluous.

> everything else with -fvisibility=hidden.
> ---
> android/Makefile.am | 3 +++
> android/hal-audio.c | 1 +
> android/hal-bluetooth.c | 1 +
> android/hal-sco.c | 1 +
> 4 files changed, 6 insertions(+)

[…]


Kind regards,

Paul

2024-01-29 19:00:37

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ v4 0/8] Remove support for external plugins

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Mon, 29 Jan 2024 14:44:14 +0000 you wrote:
> Hello everyone,
>
> With v4 we have moved from pre-processor to compilation checking for the
> external plugins support.
>
> Namely, as we build without one the dead-code elimination will discard
> all the relevant code. Ultimately this means we compile check both paths
> in order to catch mistakes. Thanks to Luiz for the suggestion.
>
> [...]

Here is the summary with links:
- [BlueZ,v4,1/8] configure, README: introduce --enable-external-plugins
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2a5c9cf632e6
- [BlueZ,v4,2/8] obexd: factor out external plugin support
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=004b5b28a04c
- [BlueZ,v4,3/8] bluetoothd: remove external-dummy plugin
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1db7a00e35c4
- [BlueZ,v4,4/8] bluetoothd: convert external sixaxis plugin to builtin
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9f71892b63f6
- [BlueZ,v4,5/8] bluetoothd: factor out external plugin support
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=109cc8a0f6aa
- [BlueZ,v4,6/8] bluetoothd: don't export internal API
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7a1d3c7c4bc7
- [BlueZ,v4,7/8] bluetoothd: change plugin loading alike obexd
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f174724c76c6
- [BlueZ,v4,8/8] android: export only (android) entrypoint from the modules
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f59f4902bc4e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html