From a5fc66c382cadd85577a7979a4db888f4fdcc419 Mon Sep 17 00:00:00 2001 From: ZmnSCPxj jxPCSnmZ Date: Wed, 5 Aug 2020 22:01:20 +0800 Subject: [PATCH] plugins/Makefile: Only link in libplugin-pay for plugins that need it. Changelog-None: cleanup only. Before this change: ``` $ ls -l plugins/bcli -rwxrwxr-x 1 zmnscpxj zmnscpxj 1914976 Aug 5 21:54 plugins/bcli ``` After this change: ``` $ ls -l plugins/bcli -rwxrwxr-x 1 zmnscpxj zmnscpxj 1830552 Aug 5 22:00 plugins/bcli ``` We already duplicate a lot of code between `lightningd` and eeach builtin plugin because we do not use .so for `common/`, but including an object file with code that is not referenced in the executable is fairly low-hanging size optimization fruit. --- plugins/Makefile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/plugins/Makefile b/plugins/Makefile index 971f589e9..562e61eb8 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -13,19 +13,25 @@ PLUGIN_BCLI_OBJS := $(PLUGIN_BCLI_SRC:.c=.o) PLUGIN_KEYSEND_SRC := plugins/keysend.c PLUGIN_KEYSEND_OBJS := $(PLUGIN_KEYSEND_SRC:.c=.o) -PLUGIN_LIB_SRC := plugins/libplugin.c plugins/libplugin-pay.c -PLUGIN_LIB_HEADER := plugins/libplugin.h plugins/libplugin-pay.h +PLUGIN_LIB_SRC := plugins/libplugin.c +PLUGIN_LIB_HEADER := plugins/libplugin.h PLUGIN_LIB_OBJS := $(PLUGIN_LIB_SRC:.c=.o) +PLUGIN_PAY_LIB_SRC := plugins/libplugin-pay.c +PLUGIN_PAY_LIB_HEADER := plugins/libplugin-pay.h +PLUGIN_PAY_LIB_OBJS := $(PLUGIN_PAY_LIB_SRC:.c=.o) + PLUGIN_ALL_SRC := \ $(PLUGIN_AUTOCLEAN_SRC) \ $(PLUGIN_BCLI_SRC) \ $(PLUGIN_FUNDCHANNEL_SRC) \ $(PLUGIN_KEYSEND_SRC) \ $(PLUGIN_LIB_SRC) \ + $(PLUGIN_PAY_LIB_SRC) \ $(PLUGIN_PAY_SRC) PLUGIN_ALL_HEADER := \ - $(PLUGIN_LIB_HEADER) + $(PLUGIN_LIB_HEADER) \ + $(PLUGIN_PAY_LIB_HEADER) PLUGIN_ALL_OBJS := $(PLUGIN_ALL_SRC:.c=.o) PLUGINS := \ @@ -74,7 +80,8 @@ PLUGIN_COMMON_OBJS := \ wire/tlvstream.o \ wire/towire.o -plugins/pay: bitcoin/chainparams.o $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/pay: bitcoin/chainparams.o $(PLUGIN_PAY_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +$(PLUGIN_PAY_OBJS): $(PLUGIN_PAY_LIB_HEADER) plugins/autoclean: bitcoin/chainparams.o $(PLUGIN_AUTOCLEAN_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) @@ -82,7 +89,8 @@ plugins/fundchannel: common/addr.o $(PLUGIN_FUNDCHANNEL_OBJS) $(PLUGIN_LIB_OBJS) plugins/bcli: bitcoin/chainparams.o $(PLUGIN_BCLI_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) -plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/gen_onion_wire.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +plugins/keysend: bitcoin/chainparams.o wire/tlvstream.o wire/gen_onion_wire.o $(PLUGIN_KEYSEND_OBJS) $(PLUGIN_LIB_OBJS) $(PLUGIN_PAY_LIB_OBJS) $(PLUGIN_COMMON_OBJS) $(JSMN_OBJS) $(CCAN_OBJS) +$(PLUGIN_KEYSEND_OBJS): $(PLUGIN_PAY_LIB_HEADER) $(PLUGIN_ALL_OBJS): $(PLUGIN_LIB_HEADER)