Makefile: create a library containing common, wire and bitcoin objects.

This means we don't have to manually choose what to link against,
which is much of the complexity of our Makefiles: the compiler will
automatically use any object files it needs to link.

We already do this for ccan as libccan.a, now we have libcommon.a.

We don't link against it for *everything*, as some tests require their own
versions.

Notes:
1. I get rid of the weird plugins/test/Makefile2 (accidental commit?)
2. Many tests change due to update-mocks.
3. In some places I added the missing dependency on the Makefile itself, though most are in the next
   patch.

Before:
	Total program size:     221366528
	Total tests size:       364243856

After:
	Total program size:     190733656
	Total tests size:       337880888

Build time from make clean (RUST=0) (includes building external libs):

Before:
	real    0m38.227000-44.245000(41.8222+/-1.6)s
	user    3m2.105000-33.696000(23.1442+/-8.4)s
	sys     0m35.054000-42.269000(39.7231+/-2)s
After:
	real    0m38.944000-40.416000(40.1131+/-0.4)s
	user    3m6.790000-17.159000(15.0571+/-2.8)s
	sys     0m35.304000-37.336000(36.8942+/-0.57)s

Build time after touch config.vars (RUST=0):

Before:
	real    0m18.928000-22.776000(21.5084+/-1.1)s
	user    2m8.613000-36.567000(27.7281+/-7.7)s
	sys     0m20.458000-23.436000(22.3963+/-0.77)s

After:
	real    0m19.831000-21.862000(21.5528+/-0.58)s
	user    2m15.361000-30.731000(28.4798+/-4.4)s
	sys     0m21.056000-22.339000(22.0346+/-0.35)s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>

rusty@rusty-Framework:~/devel/cvs/lightni
This commit is contained in:
Rusty Russell
2025-10-22 19:44:26 +10:30
parent 6b50994420
commit e120f87083
83 changed files with 430 additions and 4956 deletions

View File

@@ -13,72 +13,8 @@ FUZZ_TARGETS_SRC := $(wildcard tests/fuzz/fuzz-*.c)
FUZZ_TARGETS_OBJS := $(FUZZ_TARGETS_SRC:.c=.o)
FUZZ_TARGETS_BIN := $(FUZZ_TARGETS_SRC:.c=)
FUZZ_COMMON_OBJS := \
common/addr.o \
common/amount.o \
common/autodata.o \
common/base32.o \
common/base64.o \
common/bech32.o \
common/bech32_util.o \
common/bigsize.o \
common/bip32.o \
common/blockheight_states.o \
common/bolt11.o \
common/bolt12_merkle.o \
common/channel_config.o \
common/channel_id.o \
common/channel_type.o \
common/close_tx.o \
common/configdir.o \
common/configvar.o \
common/codex32.o \
common/cryptomsg.o \
common/daemon.o \
common/daemon_conn.o \
common/derive_basepoints.o \
common/descriptor_checksum.o \
common/features.o \
common/fee_states.o \
common/hash_u5.o \
common/hsm_encryption.o \
common/htlc_state.o \
common/initial_channel.o \
common/initial_commit_tx.o \
common/key_derive.o \
common/keyset.o \
common/memleak.o \
common/msg_queue.o \
common/node_id.o \
common/permute_tx.o \
common/psbt_keypath.o \
common/sciddir_or_pubkey.o \
common/setup.o \
common/status.o \
common/status_wire.o \
common/status_wiregen.o \
common/utils.o \
common/version.o \
common/wireaddr.o \
wire/bolt12_wiregen.o \
wire/channel_type_wiregen.o \
wire/fromwire.o \
wire/onion_wiregen.o \
wire/peer_wire.o \
wire/peer_wiregen.o \
wire/tlvstream.o \
wire/towire.o \
wire/wire_io.o \
wire/wire_sync.o
$(FUZZ_TARGETS_OBJS): $(COMMON_HEADERS) $(WIRE_HEADERS) $(COMMON_SRC)
$(FUZZ_TARGETS_BIN): $(LIBFUZZ_OBJS) $(FUZZ_COMMON_OBJS) $(BITCOIN_OBJS)
tests/fuzz/fuzz-error-warning: common/peer_billboard.o \
common/wire_error.o \
common/peer_io.o \
common/read_peer_msg.o \
common/peer_status_wiregen.o
$(FUZZ_TARGETS_BIN): $(LIBFUZZ_OBJS) libcommon.a
ALL_C_SOURCES += $(FUZZ_TARGETS_SRC) $(LIBFUZZ_SRC)
ALL_FUZZ_TARGETS += $(FUZZ_TARGETS_BIN)