Skip to content

Commit 73d7607

Browse files
committed
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 <rusty@rustcorp.com.au>
1 parent d7a7e1c commit 73d7607

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,9 @@ ifeq ($(STATIC),1)
290290
# For MacOS, Jacob Rapoport <jacob@rumblemonkey.com> changed this to:
291291
# -L/usr/local/lib -lsqlite3 -lz -Wl,-lm -lpthread -ldl $(COVFLAGS)
292292
# But that doesn't static link.
293-
LDLIBS = -L$(CPATH) -Wl,-dn $(SQLITE3_LDLIBS) -Wl,-dy -lm -lpthread -ldl $(COVFLAGS)
293+
LDLIBS = -L$(CPATH) -Wl,-dn $(SQLITE3_LDLIBS) -Wl,-dy -lm -lpthread -ldl $(COVFLAGS) -Wl,--gc-sections
294294
else
295-
LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) $(COVFLAGS)
295+
LDLIBS = -L$(CPATH) -lm $(SQLITE3_LDLIBS) $(COVFLAGS) -Wl,--gc-sections
296296
endif
297297

298298
# If we have the postgres client library we need to link against it as well

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ usage_with_default()
4646
# Given DEBUGBUILD, what COPTFLAGS do we default to.
4747
default_coptflags()
4848
{
49+
echo -n "-ffunction-sections"
4950
if [ "$1" = 0 ]; then
50-
echo "-Og"
51+
echo " -Og"
5152
fi
5253
}
5354

0 commit comments

Comments
 (0)