From 744432dd63f04f6e4286454adea8e8303f9cded8 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 27 Jan 2026 12:37:11 +1030 Subject: [PATCH] Build: add function sections. This allows further reduction in binary sizes. Size of all user before: text data bss dec hex filename 64277932 904968 317576 65500476 3e7753c (TOTALS) After: 52443036 729560 271720 53444316 32f7edc (TOTALS) Some are dramatic, such as lightning-cli not pulling in libbacktrace: 174454 2880 296 177630 2b5de cli/lightning-cli 56633 2608 232 59473 e851 cli/lightning-cli But most things get a 25% trim: 3972339 363568 21760 4357667 427e23 lightningd/lightningd 3300337 247768 21664 3569769 367869 lightningd/lightningd Changelog-Changed: Build: most binaries are now about 20% smaller. Signed-off-by: Rusty Russell --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 0b7b88f86..97983e6a8 100644 --- a/Makefile +++ b/Makefile @@ -313,6 +313,10 @@ else LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) $(COVFLAGS) endif +ifeq ($(HAVE_FUNCTION_SECTIONS),1) +LDLIBS += -Wl,--gc-sections +endif + # If we have the postgres client library we need to link against it as well ifeq ($(HAVE_POSTGRES),1) LDLIBS += $(POSTGRES_LDLIBS)