Skip to content

Commit 98b61aa

Browse files
committed
Merge branch 'jk/cocci-batch' into jch
Optionally "make coccicheck" can feed multiple source files to spatch, gaining performance while spending more memory. * jk/cocci-batch: coccicheck: make batch size of 0 mean "unlimited" coccicheck: optionally batch spatch invocations
2 parents 3bda004 + bcb4edf commit 98b61aa

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

Makefile

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,11 @@ PTHREAD_CFLAGS =
11731173
SPARSE_FLAGS ?=
11741174
SP_EXTRA_FLAGS =
11751175

1176-
# For the 'coccicheck' target
1176+
# For the 'coccicheck' target; setting SPATCH_BATCH_SIZE higher will
1177+
# usually result in less CPU usage at the cost of higher peak memory.
1178+
# Setting it to 0 will feed all files in a single spatch invocation.
11771179
SPATCH_FLAGS = --all-includes --patch .
1180+
SPATCH_BATCH_SIZE = 1
11781181

11791182
include config.mak.uname
11801183
-include config.mak.autogen
@@ -2809,12 +2812,14 @@ endif
28092812

28102813
%.cocci.patch: %.cocci $(COCCI_SOURCES)
28112814
@echo ' ' SPATCH $<; \
2812-
ret=0; \
2813-
for f in $(COCCI_SOURCES); do \
2814-
$(SPATCH) --sp-file $< $$f $(SPATCH_FLAGS) || \
2815-
{ ret=$$?; break; }; \
2816-
done >$@+ 2>$@.log; \
2817-
if test $$ret != 0; \
2815+
if test $(SPATCH_BATCH_SIZE) = 0; then \
2816+
limit=; \
2817+
else \
2818+
limit='-n $(SPATCH_BATCH_SIZE)'; \
2819+
fi; \
2820+
if ! echo $(COCCI_SOURCES) | xargs $$limit \
2821+
$(SPATCH) --sp-file $< $(SPATCH_FLAGS) \
2822+
>$@+ 2>$@.log; \
28182823
then \
28192824
cat $@.log; \
28202825
exit 1; \

0 commit comments

Comments
 (0)