[PATCH BlueZ 09/10] build: enable gc/dead code removal

Emil Velikov via B4 Relay
2024-01-16T13:51:59Z

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(+)

diff --git a/acinclude.m4 b/acinclude.m4
index c5d6de7b3..4b73a5bfc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -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)
])

--
2.43.0