Skip to content

Commit

Permalink
Makefile: don't make every file depend on version headers.
Browse files Browse the repository at this point in the history
common/version.o depends on common/version_gen.h explicitly already,
and header_versions_gen.h is only used by lightningd, so we can make
that dependency explicit.

This means when version changes (i.e. different git commit) we only
relink, not recompile.

Before:
```
real	0m6.578s
user	0m14.705s
sys	0m13.621s
```

After:
```
real	0m2.098s
user	0m6.763s
sys	0m4.844s
```

Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell authored and vincenzopalazzo committed Jul 2, 2024
1 parent d922c89 commit 7ef8645
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ ALL_TEST_PROGRAMS :=
ALL_TEST_GEN :=
ALL_FUZZ_TARGETS :=
ALL_C_SOURCES :=
ALL_C_HEADERS := header_versions_gen.h version_gen.h
ALL_C_HEADERS :=
# Extra (non C) targets that should be built by default.
DEFAULT_TARGETS :=

Expand Down Expand Up @@ -640,7 +640,7 @@ version_gen.h: $(FORCE)
endif

# That forces this rule to be run every time, too.
header_versions_gen.h: tools/headerversions
header_versions_gen.h: tools/headerversions $(FORCE)
@tools/headerversions $@

# We make a static library, this way linker can discard unused parts.
Expand Down
3 changes: 3 additions & 0 deletions lightningd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ ALL_C_SOURCES += $(LIGHTNINGD_SRC) $(LIGHTNINGD_SRC_NOHDR)
ALL_C_HEADERS += $(LIGHTNINGD_HDRS)
ALL_PROGRAMS += lightningd/lightningd

# We explicitly check header versions in lightningd.c
lightningd/lightningd.o: header_versions_gen.h

# Common source we use.
LIGHTNINGD_COMMON_OBJS := \
common/addr.o \
Expand Down

0 comments on commit 7ef8645

Please sign in to comment.