Skip to contentSkip to conversation

Autotools papercuts, linker GC, symlink dbus-org.bluez.obex.service

PATCH Applied Emil Velikov 3 participants 9 messages Jan 24, 2024 – Jan 25, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover Autotools papercuts, linker GC, symlink dbus-org.bluez.obex.service

Hello everyone,

Here is v2 of the autotoo papercuts.

Changes in this revision:
- dropped already merged patches - thanks o/
- drop "build: remove dummy {conf,state}{dir,_DATA}" patch

The latter patch was causing some unexpected and unrelated issues with the CI. At a glance I couldn't quite track down why, it removes some dead code and reproducing the CI is a time sink ... So I caved in :-P

Link to the original v1 cover letter and patches can be found below.

Thanks
Emil

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

---
Emil Velikov (6):
build: remove unused variable builtin_nodist
build: remove .service files from DEPENDENCIES lists
build: remove explicit DEPENDENCIES handling
build: manage .service.in files via configure.ac
build: enable gc/dead code removal
build: install dbus-org.bluez.obex.service symlink

 Makefile.am                       | 25 +++----------------------
 Makefile.mesh                     |  7 +------
 Makefile.obexd                    | 10 ++++++++--
 Makefile.tools                    |  6 ------
 acinclude.m4                      |  2 ++
 configure.ac                      | 11 ++++++++++-
 mesh/bluetooth-mesh.service.in    |  2 +-
 obexd/src/obex.service.in         |  2 +-
 src/bluetooth.service.in          |  2 +-
 tools/bluetooth-logger.service.in |  2 +-
 10 files changed, 28 insertions(+), 41 deletions(-)

---
base-commit: a9d1f6f6a625607de6c3f5b7a40a3aac5f36c02b
change-id: 20240116-autofoo-db2fe2c70951

Best regards,

Signature · 1 line
Emil Velikov <[email protected]>
#1 lore raw

PATCH v2 1/6 build: remove unused variable builtin_nodist

From: Emil Velikov <[email protected]>

---
 Makefile.am | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile.am +1 -2
index e738eb3a5..a470e40cf 100644
@@ -288,7 +288,6 @@ gobex_sources = gobex/gobex.h gobex/gobex.c \
 builtin_modules =
 builtin_sources =
 builtin_cppflags =
-builtin_nodist =
 builtin_ldadd =
 
 include Makefile.plugins
@@ -350,7 +349,7 @@ src_bluetoothd_CPPFLAGS = $(AM_CPPFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
 					$(BACKTRACE_CFLAGS) $(builtin_cppflags)
 src_bluetoothd_SHORTNAME = bluetoothd
 
-builtin_files = src/builtin.h $(builtin_nodist)
+builtin_files = src/builtin.h
 
 nodist_src_bluetoothd_SOURCES = $(builtin_files)
 
Signature · 1 line
2.43.0
#2 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=819560

---Test result---

Test Summary:

CheckPatch                    PASS      2.17 seconds
GitLint                       PASS      1.67 seconds
BuildEll                      PASS      24.22 seconds
BluezMake                     PASS      734.57 seconds
MakeCheck                     PASS      12.13 seconds
MakeDistcheck                 PASS      166.26 seconds
CheckValgrind                 PASS      228.88 seconds
CheckSmatch                   PASS      332.09 seconds
bluezmakeextell               PASS      108.61 seconds
IncrementalBuild              PASS      4118.59 seconds
ScanBuild                     PASS      966.75 seconds

---
Regards,
Linux Bluetooth

#3 lore raw

PATCH v2 2/6 build: remove .service files from DEPENDENCIES lists

In reply to Emil Velikov

From: Emil Velikov <[email protected]>

The DEPENDENCES lists are for binary objects, while the service files are required by systemd (et al) after the install stage. The services files are referenced by _DATA, so the service.in -> service conversion can happen then.

---
 Makefile.am    | 3 +--
 Makefile.mesh  | 3 +--
 Makefile.tools | 3 +--
 3 files changed, 3 insertions(+), 6 deletions(-)
Makefile.am +1 -2
index a470e40cf..be8f74f13 100644
@@ -341,8 +341,7 @@ src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
 
 src_bluetoothd_DEPENDENCIES = lib/libbluetooth-internal.la \
 				gdbus/libgdbus-internal.la \
-				src/libshared-glib.la \
-				src/bluetooth.service
+				src/libshared-glib.la
 
 src_bluetoothd_CPPFLAGS = $(AM_CPPFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
 					-DPLUGINDIR=\""$(build_plugindir)"\" \
Makefile.mesh +1 -2
index 63f085de1..a66e47442 100644
@@ -45,8 +45,7 @@ mesh/main.$(OBJEXT): src/builtin.h lib/bluetooth/bluetooth.h
 
 mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c
 mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c
-mesh_bluetooth_meshd_DEPENDENCIES = $(ell_dependencies) src/libshared-ell.la \
-				mesh/bluetooth-mesh.service
+mesh_bluetooth_meshd_DEPENDENCIES = $(ell_dependencies) src/libshared-ell.la
 
 if MANPAGES
 man_MANS += mesh/bluetooth-meshd.8
Makefile.tools +1 -2
index e541084e9..6fda3f51d 100644
@@ -71,8 +71,7 @@ pkglibexec_PROGRAMS += tools/btmon-logger
 
 tools_btmon_logger_SOURCES = tools/btmon-logger.c
 tools_btmon_logger_LDADD = src/libshared-mainloop.la
-tools_btmon_logger_DEPENDENCIES = src/libshared-mainloop.la \
-					tools/bluetooth-logger.service
+tools_btmon_logger_DEPENDENCIES = src/libshared-mainloop.la
 
 if SYSTEMD
 systemdsystemunit_DATA += tools/bluetooth-logger.service
Signature · 1 line
2.43.0
#4 lore raw

PATCH v2 3/6 build: remove explicit DEPENDENCIES handling

In reply to Emil Velikov

From: Emil Velikov <[email protected]>

We currently duplicate the DEPENDENCIES handling that autotools does for us. We have two types of objects - libraries or generated headers.

Former are part of the LDADD, the latter in BUILT_SOURCES.

---
 Makefile.am    | 7 -------
 Makefile.mesh  | 1 -
 Makefile.tools | 2 --
 3 files changed, 10 deletions(-)
Makefile.am +0 -7
index be8f74f13..b913402b3 100644
@@ -83,7 +83,6 @@ lib_LTLIBRARIES += lib/libbluetooth.la
 
 lib_libbluetooth_la_SOURCES = $(lib_headers) $(lib_sources)
 lib_libbluetooth_la_LDFLAGS = $(AM_LDFLAGS) -version-info 22:12:19
-lib_libbluetooth_la_DEPENDENCIES = $(local_headers)
 endif
 
 noinst_LTLIBRARIES += lib/libbluetooth-internal.la
@@ -100,12 +99,10 @@ gdbus_libgdbus_internal_la_SOURCES = gdbus/gdbus.h \
 if EXTERNAL_ELL
 ell_cflags = @ELL_CFLAGS@
 ell_ldadd = @ELL_LIBS@
-ell_dependencies =
 ell_built_sources = ell/shared
 else
 ell_cflags =
 ell_ldadd = ell/libell-internal.la
-ell_dependencies = $(ell_ldadd)
 ell_built_sources = ell/shared ell/internal ell/ell.h
 
 noinst_LTLIBRARIES += ell/libell-internal.la
@@ -339,10 +336,6 @@ src_bluetoothd_LDADD = lib/libbluetooth-internal.la \
 src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
 				-Wl,--version-script=$(srcdir)/src/bluetooth.ver
 
-src_bluetoothd_DEPENDENCIES = lib/libbluetooth-internal.la \
-				gdbus/libgdbus-internal.la \
-				src/libshared-glib.la
-
 src_bluetoothd_CPPFLAGS = $(AM_CPPFLAGS) -DBLUETOOTH_PLUGIN_BUILTIN \
 					-DPLUGINDIR=\""$(build_plugindir)"\" \
 					$(BACKTRACE_CFLAGS) $(builtin_cppflags)
Makefile.mesh +0 -1
index a66e47442..45fa90339 100644
@@ -45,7 +45,6 @@ mesh/main.$(OBJEXT): src/builtin.h lib/bluetooth/bluetooth.h
 
 mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c
 mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c
-mesh_bluetooth_meshd_DEPENDENCIES = $(ell_dependencies) src/libshared-ell.la
 
 if MANPAGES
 man_MANS += mesh/bluetooth-meshd.8
Makefile.tools +0 -2
index 6fda3f51d..1cde39f94 100644
@@ -71,7 +71,6 @@ pkglibexec_PROGRAMS += tools/btmon-logger
 
 tools_btmon_logger_SOURCES = tools/btmon-logger.c
 tools_btmon_logger_LDADD = src/libshared-mainloop.la
-tools_btmon_logger_DEPENDENCIES = src/libshared-mainloop.la
 
 if SYSTEMD
 systemdsystemunit_DATA += tools/bluetooth-logger.service
@@ -577,7 +576,6 @@ noinst_PROGRAMS += tools/btpclient tools/btpclientctl
 tools_btpclient_SOURCES = tools/btpclient.c src/shared/btp.c src/shared/btp.h
 tools_btpclient_LDADD = lib/libbluetooth-internal.la \
 				src/libshared-ell.la $(ell_ldadd)
-tools_btpclient_DEPENDENCIES = lib/libbluetooth-internal.la $(ell_dependencies)
 tools/btpclient.$(OBJEXT): src/libshared-ell.la ell/internal
 
 tools_btpclientctl_SOURCES = tools/btpclientctl.c client/display.c
Signature · 1 line
2.43.0
#5 lore raw

PATCH v2 4/6 build: manage .service.in files via configure.ac

In reply to Emil Velikov

From: Emil Velikov <[email protected]>

Considering we do basic substitution, we don't need to manually sed, track dependencies, dist nor clean. Just add the files to AC_CONFIG_FILES() call it a day - it does everything for us.

---
 Makefile.am                       | 14 ++------------
 Makefile.mesh                     |  5 +----
 Makefile.obexd                    |  4 ++--
 Makefile.tools                    |  3 ---
 configure.ac                      | 11 ++++++++++-
 mesh/bluetooth-mesh.service.in    |  2 +-
 obexd/src/obex.service.in         |  2 +-
 src/bluetooth.service.in          |  2 +-
 tools/bluetooth-logger.service.in |  2 +-
 9 files changed, 19 insertions(+), 26 deletions(-)
Makefile.am +2 -12
index b913402b3..59603a0b7 100644
@@ -47,7 +47,7 @@ dbussystembusdir = $(DBUS_SYSTEMBUSDIR)
 dbussystembus_DATA = src/org.bluez.service
 endif
 
-EXTRA_DIST += src/bluetooth.service.in src/org.bluez.service
+EXTRA_DIST += src/org.bluez.service
 
 plugindir = $(libdir)/bluetooth/plugins
 
@@ -345,7 +345,7 @@ builtin_files = src/builtin.h
 
 nodist_src_bluetoothd_SOURCES = $(builtin_files)
 
-CLEANFILES += $(builtin_files) src/bluetooth.service
+CLEANFILES += $(builtin_files)
 
 if MANPAGES
 man_MANS += src/bluetoothd.8
@@ -736,13 +736,6 @@ MAINTAINERCLEANFILES = Makefile.in \
 	aclocal.m4 configure config.h.in config.sub config.guess \
 	ltmain.sh depcomp compile missing install-sh mkinstalldirs test-driver
 
-SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
-		$(SED) -e 's,@pkglibexecdir\@,$(pkglibexecdir),g' \
-		       -e 's,@libexecdir\@,$(libexecdir),g' \
-		       -e 's,@statedir\@,$(statedir),g' \
-		       -e 's,@confdir\@,$(confdir),g' \
-		< $< > $@
-
 if RUN_RST2MAN
 RST2MAN_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 			$(RST2MAN) --strict --no-raw \
@@ -752,9 +745,6 @@ RST2MAN_PROCESS = $(AM_V_GEN)test -f $@ || \
 		{ echo "Generated manual page $@ does not exist"; false; }
 endif
 
-%.service: %.service.in Makefile
-	$(SED_PROCESS)
-
 %.1: %.rst Makefile
 	$(RST2MAN_PROCESS)
 
Makefile.mesh +1 -4
index 45fa90339..ea50383d2 100644
@@ -51,9 +51,6 @@ man_MANS += mesh/bluetooth-meshd.8
 endif
 manual_pages += mesh/bluetooth-meshd.8
 
-CLEANFILES += mesh/bluetooth-mesh.service
-
 endif
 
-EXTRA_DIST += mesh/bluetooth-mesh.conf mesh/bluetooth-mesh.service.in \
-		mesh/org.bluez.mesh.service mesh/mesh-main.conf
+EXTRA_DIST += mesh/bluetooth-mesh.conf mesh/org.bluez.mesh.service mesh/mesh-main.conf
Makefile.obexd +2 -2
index 5d1a4ff65..c2b5c6d7a 100644
@@ -7,7 +7,7 @@ dbussessionbusdir = $(DBUS_SESSIONBUSDIR)
 dbussessionbus_DATA = obexd/src/org.bluez.obex.service
 endif
 
-EXTRA_DIST += obexd/src/obex.service.in obexd/src/org.bluez.obex.service
+EXTRA_DIST += obexd/src/org.bluez.obex.service
 
 if OBEX
 
@@ -112,6 +112,6 @@ obexd/src/builtin.h: obexd/src/genbuiltin $(obexd_builtin_sources)
 	$(AM_V_at)$(MKDIR_P) $(dir $@)
 	$(AM_V_GEN)$(srcdir)/obexd/src/genbuiltin $(obexd_builtin_modules) > $@
 
-CLEANFILES += obexd/src/builtin.h $(builtin_files) obexd/src/obex.service
+CLEANFILES += obexd/src/builtin.h
 
 EXTRA_DIST += obexd/src/genbuiltin
Makefile.tools +0 -3
index 1cde39f94..044342e29 100644
@@ -77,9 +77,6 @@ systemdsystemunit_DATA += tools/bluetooth-logger.service
 endif
 endif
 
-CLEANFILES += tools/bluetooth-logger.service
-EXTRA_DIST += tools/bluetooth-logger.service.in
-
 if TESTING
 noinst_PROGRAMS += emulator/btvirt emulator/b1ee emulator/hfp \
 					peripheral/btsensor tools/3dsp \
configure.ac +10 -1
index cab5da581..b4d362494 100644
@@ -441,5 +441,14 @@ if (test "${plugin_phonebook}" = "ebook"); then
 fi
 AC_SUBST(PLUGIN_PHONEBOOK, [${plugin_phonebook}])
 
-AC_CONFIG_FILES(Makefile src/bluetoothd.rst lib/bluez.pc mesh/bluetooth-meshd.rst)
+AC_CONFIG_FILES(
+	lib/bluez.pc
+	Makefile
+	mesh/bluetooth-meshd.rst
+	mesh/bluetooth-mesh.service
+	obexd/src/obex.service
+	src/bluetoothd.rst
+	src/bluetooth.service
+	tools/bluetooth-logger.service
+)
 AC_OUTPUT
mesh/bluetooth-mesh.service.in +1 -1
index c8afbf53e..9c3ff01a3 100644
@@ -5,7 +5,7 @@ ConditionPathIsDirectory=/sys/class/bluetooth
 [Service]
 Type=dbus
 BusName=org.bluez.mesh
-ExecStart=@pkglibexecdir@/bluetooth-meshd
+ExecStart=@exec_prefix@/bluetooth/bluetooth-meshd
 NotifyAccess=main
 LimitNPROC=1
 ProtectHome=true
obexd/src/obex.service.in +1 -1
index fc0dce993..03d09a679 100644
@@ -4,7 +4,7 @@ Description=Bluetooth OBEX service
 [Service]
 Type=dbus
 BusName=org.bluez.obex
-ExecStart=@pkglibexecdir@/obexd
+ExecStart=@exec_prefix@/bluetooth/obexd
 
 [Install]
 Alias=dbus-org.bluez.obex.service
src/bluetooth.service.in +1 -1
index beb98ce0c..63e157587 100644
@@ -6,7 +6,7 @@ ConditionPathIsDirectory=/sys/class/bluetooth
 [Service]
 Type=dbus
 BusName=org.bluez
-ExecStart=@pkglibexecdir@/bluetoothd
+ExecStart=@exec_prefix@/bluetooth/bluetoothd
 NotifyAccess=main
 #WatchdogSec=10
 #Restart=on-failure
tools/bluetooth-logger.service.in +1 -1
index 009002731..5657c8d84 100644
@@ -4,7 +4,7 @@ ConditionPathIsDirectory=/sys/class/bluetooth
 
 [Service]
 Type=simple
-ExecStart=@pkglibexecdir@/btmon-logger -p -b /var/log/bluetooth/hci.log
+ExecStart=@exec_prefix@/bluetooth/btmon-logger -p -b /var/log/bluetooth/hci.log
 NotifyAccess=main
 CapabilityBoundingSet=CAP_NET_RAW
 LimitNPROC=1
Signature · 1 line
2.43.0
#6 lore raw

PATCH v2 5/6 build: enable gc/dead code removal

In reply to Emil Velikov

From: Emil Velikov <[email protected]>

Currently, there's plenty of unused code in most binaries. Enable -fdata/function-sections, which allows the linker garbage collection to do its job.

On a maintainer build, this reduces the (unstriped) binaries from 117 to 114MiB.

---
 acinclude.m4 | 2 ++
 1 file changed, 2 insertions(+)
acinclude.m4 +2 -0
index c5d6de7b3..4b73a5bfc 100644
@@ -134,6 +134,8 @@ AC_DEFUN([MISC_FLAGS], [
 		misc_cflags="$misc_cflags --coverage"
 		misc_ldflags="$misc_ldflags --coverage"
 	fi
+	misc_cflags="$misc_cflags -ffunction-sections -fdata-sections"
+	misc_ldflags="$misc_ldflags -Wl,--gc-sections"
 	AC_SUBST([MISC_CFLAGS], $misc_cflags)
 	AC_SUBST([MISC_LDFLAGS], $misc_ldflags)
 ])
Signature · 1 line
2.43.0
#7 lore raw

PATCH v2 6/6 build: install dbus-org.bluez.obex.service symlink

In reply to Emil Velikov

From: Emil Velikov <[email protected]>

obex.service has an alias(dbus-org.bluez.obex.service) which is created as it's enabled. At the same time, the dbus service references the alias itself.

Thus the dbus socket activation can happen, only when the service is already enabled/running... Which defeats the whole purpose.

Create/install the respective symlink/alias, so that any user looking for the dbus will start it.

Note: we need a hook here instead of LN_S to create the in-tree file, since `install' aggressively dereferences it.

---
 Makefile.obexd | 6 ++++++
 1 file changed, 6 insertions(+)
Makefile.obexd +6 -0
index c2b5c6d7a..363295d0e 100644
@@ -3,6 +3,12 @@ if SYSTEMD
 systemduserunitdir = $(SYSTEMD_USERUNITDIR)
 systemduserunit_DATA = obexd/src/obex.service
 
+install-data-hook:
+	$(LN_S) -f obex.service $(DESTDIR)$(SYSTEMD_USERUNITDIR)/dbus-org.bluez.obex.service
+
+uninstall-hook:
+	rm -f $(DESTDIR)$(SYSTEMD_USERUNITDIR)/dbus-org.bluez.obex.service
+
 dbussessionbusdir = $(DBUS_SESSIONBUSDIR)
 dbussessionbus_DATA = obexd/src/org.bluez.obex.service
 endif
Signature · 1 line
2.43.0
#8 lore raw
In reply to Emil Velikov
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 24 Jan 2024 16:20:05 +0000 you wrote:

Hello everyone,

Here is v2 of the autotoo papercuts.

Changes in this revision:
- dropped already merged patches - thanks o/
- drop "build: remove dummy {conf,state}{dir,_DATA}" patch

[...]

Here is the summary with links:
- [BlueZ,v2,1/6] build: remove unused variable builtin_nodist

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=215e6c7083da
  - [BlueZ,v2,2/6] build: remove .service files from DEPENDENCIES lists
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=14c7f21292b1
  - [BlueZ,v2,3/6] build: remove explicit DEPENDENCIES handling
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=808d008aace3
  - [BlueZ,v2,4/6] build: manage .service.in files via configure.ac
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=116524c01de4
  - [BlueZ,v2,5/6] build: enable gc/dead code removal
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=10d6d908b5fe
  - [BlueZ,v2,6/6] build: install dbus-org.bluez.obex.service symlink
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=1cd6c874c271

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html