Skip to content

Conversation

@rustyrussell
Copy link
Contributor

This gives us a 20% reduction in in-memory sizes for non-Rust binaries.

Users care about memory more than disk, and they care about programs
they run more than our test programs and tools.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
@rustyrussell rustyrussell added this to the v25.12 milestone Nov 4, 2025
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 <rusty@rustcorp.com.au>
@rustyrussell rustyrussell force-pushed the guilt/try-function-sections branch from 73d7607 to 38635c0 Compare November 4, 2025 02:28
@Lagrang3
Copy link
Collaborator

Lagrang3 commented Nov 4, 2025

If I don't build manually tools/lightning-hsmtool I get the following error

$ uv run make print-binary-sizes
User programs:
   text	   data	    bss	    dec	    hex	filename
2207578	   6736	   4928	2219242	 21dcea	lightningd/lightning_channeld
...
 180194	   2840	    296	 183330	  2cc22	cli/lightning-cli
4015976	 363400	  21760	4401136	 4327f0	lightningd/lightningd
size: 'tools/lightning-hsmtool': No such file
2057558	   6344	   4768	2068670	 1f90be	plugins/autoclean
...
2186875	   9280	   4704	2200859	 21951b	plugins/bookkeeper
177776820	5769632	 322872	183869324	af59f8c	(TOTALS)
make: *** [Makefile:1111: print-binary-sizes] Error 1

The problem is that ALL_PROGRAMS contain tools/hsmtool but not tools/lightning-hsmtool.
The latter is instead found in BIN_PROGRAMS and it is a dependency of the make install target.
A fix could be to make print-binary-sizes dependent on BIN_PROGRAMS as well.

diff --git a/Makefile b/Makefile
index 5c93e6145..4798fc59d 100644
--- a/Makefile
+++ b/Makefile
@@ -1106,7 +1106,7 @@ ccan-rune-rune.o: $(CCANDIR)/ccan/rune/rune.c
 ccan-rune-coding.o: $(CCANDIR)/ccan/rune/coding.c
        @$(call VERBOSE, "cc $<", $(CC) $(CFLAGS) -c -o $@ $<)
 
-print-binary-sizes: $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS)
+print-binary-sizes: $(ALL_PROGRAMS) $(ALL_TEST_PROGRAMS) $(BIN_PROGRAMS)
        @echo User programs:
        @size -t $(PKGLIBEXEC_PROGRAMS) $(filter-out tools/reckless,$(BIN_PROGRAMS)) $(PLUGINS)
        @echo All programs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants