lightning
lightning copied to clipboard
Use -ffunction-sections to build smaller binaries
This gives us a 20% reduction in in-memory sizes for non-Rust binaries.
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: