mbox series

[0/5] cocci: make "incremental" possible + a ccache-like tool

Message ID cover-0.5-00000000000-20220825T141212Z-avarab@gmail.com (mailing list archive)
Headers show
Series cocci: make "incremental" possible + a ccache-like tool | expand

Message

Ævar Arnfjörð Bjarmason Aug. 25, 2022, 2:36 p.m. UTC
This series makes the "coccicheck" rule incremental by only re-running
"spatch" for those file/rule combinations that changed.

The result is that e.g. running "make coccicheck" followed by a:

	make -W grep.c coccicheck

Will take around 2s instead of a *lot* longer. The 3/5 change has all
the details about this, and why it's safe.

Furthermore we'll properly handle re-building if any of the required
headers change (e.g. column.h).

I had a previous stab at trying to make "coccicheck" faster a while
ago in [1], but that was fatally flawed because it would break in
cases where grep.c e.g. dependen on a header that changed.

This series doesn't suffer from that issue, because we piggy-back on
the corresponding .depend/* files to extract dependency info. This
does mean that the incremental speed-ups depend on
COMPUTE_HEADER_DEPENDENCIES=yes (which is the case with "gcc" and
"clang" by default).

I've been running with this series locally for a while. I think it
should fully solve the lamentations about the coccicheck being too
slow (e.g. in [2]), particularly when paired with the new
"spatchcache" helper added in 5/5.

Even without that helper running "make coccicheck" e.g. after applying
a patch series now becomes viable, provided the patches don't modify
one of the "rebuild everything" files we have (such as cache.h and
git-compat-util.h).

1. https://lore.kernel.org/git/20210302205103.12230-1-avarab@gmail.com/
2. https://lore.kernel.org/git/xmqqh7249b8d.fsf@gitster.g/

Ævar Arnfjörð Bjarmason (5):
  Makefile: add ability to TAB-complete cocci *.patch rules
  Makefile: have "coccicheck" re-run if flags change
  cocci: make "coccicheck" rule incremental
  cocci: make incremental compilation even faster
  spatchcache: add a ccache-alike for "spatch"

 .gitignore                                    |   1 +
 Makefile                                      | 114 +++++++--
 contrib/coccinelle/spatchcache                | 217 ++++++++++++++++++
 .../coccinelle/the_repository.pending.cocci   |   1 -
 shared.mak                                    |   4 +-
 5 files changed, 310 insertions(+), 27 deletions(-)
 create mode 100755 contrib/coccinelle/spatchcache