Skip to content

Commit 473dcb4

Browse files
committed
Merge branch 'js/build-fuzz-more-often'
In addition to building the objects needed, try to link the objects that are used in fuzzer tests, to make sure at least they build without bitrot, in Linux CI runs. * js/build-fuzz-more-often: fuzz: link fuzz programs with `make all` on Linux
2 parents 07410bb + 8427b7e commit 473dcb4

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

Makefile

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,9 @@ include shared.mak
409409
# to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c`
410410
# that implements the `fsm_os_settings__*()` routines.
411411
#
412+
# Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
413+
# programs in oss-fuzz/.
414+
#
412415
# === Optional library: libintl ===
413416
#
414417
# Define NO_GETTEXT if you don't want Git output to be translated.
@@ -752,23 +755,6 @@ SCRIPTS = $(SCRIPT_SH_GEN) \
752755

753756
ETAGS_TARGET = TAGS
754757

755-
# If you add a new fuzzer, please also make sure to run it in
756-
# ci/run-build-and-minimal-fuzzers.sh so that we make sure it still links and
757-
# runs in the future.
758-
FUZZ_OBJS += oss-fuzz/dummy-cmd-main.o
759-
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
760-
FUZZ_OBJS += oss-fuzz/fuzz-config.o
761-
FUZZ_OBJS += oss-fuzz/fuzz-date.o
762-
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
763-
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
764-
.PHONY: fuzz-objs
765-
fuzz-objs: $(FUZZ_OBJS)
766-
767-
# Always build fuzz objects even if not testing, to prevent bit-rot.
768-
all:: $(FUZZ_OBJS)
769-
770-
FUZZ_PROGRAMS += $(patsubst %.o,%,$(filter-out %dummy-cmd-main.o,$(FUZZ_OBJS)))
771-
772758
# Empty...
773759
EXTRA_PROGRAMS =
774760

@@ -2373,6 +2359,29 @@ ifndef NO_TCLTK
23732359
endif
23742360
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1) SHELL_PATH='$(SHELL_PATH_SQ)' PERL_PATH='$(PERL_PATH_SQ)'
23752361

2362+
# If you add a new fuzzer, please also make sure to run it in
2363+
# ci/run-build-and-minimal-fuzzers.sh so that we make sure it still links and
2364+
# runs in the future.
2365+
FUZZ_OBJS += oss-fuzz/dummy-cmd-main.o
2366+
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
2367+
FUZZ_OBJS += oss-fuzz/fuzz-config.o
2368+
FUZZ_OBJS += oss-fuzz/fuzz-date.o
2369+
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
2370+
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
2371+
.PHONY: fuzz-objs
2372+
fuzz-objs: $(FUZZ_OBJS)
2373+
2374+
# Always build fuzz objects even if not testing, to prevent bit-rot.
2375+
all:: $(FUZZ_OBJS)
2376+
2377+
FUZZ_PROGRAMS += $(patsubst %.o,%,$(filter-out %dummy-cmd-main.o,$(FUZZ_OBJS)))
2378+
2379+
# Build fuzz programs when possible, even without the necessary fuzzing support,
2380+
# to prevent bit-rot.
2381+
ifdef LINK_FUZZ_PROGRAMS
2382+
all:: $(FUZZ_PROGRAMS)
2383+
endif
2384+
23762385
please_set_SHELL_PATH_to_a_more_modern_shell:
23772386
@$$(:)
23782387

@@ -3858,22 +3867,22 @@ cover_db_html: cover_db
38583867
#
38593868
# An example command to build against libFuzzer from LLVM 11.0.0:
38603869
#
3861-
# make CC=clang CXX=clang++ \
3870+
# make CC=clang FUZZ_CXX=clang++ \
38623871
# CFLAGS="-fsanitize=fuzzer-no-link,address" \
38633872
# LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
38643873
# fuzz-all
38653874
#
3875+
FUZZ_CXX ?= $(CC)
38663876
FUZZ_CXXFLAGS ?= $(ALL_CFLAGS)
38673877

38683878
.PHONY: fuzz-all
3879+
fuzz-all: $(FUZZ_PROGRAMS)
38693880

38703881
$(FUZZ_PROGRAMS): %: %.o oss-fuzz/dummy-cmd-main.o $(GITLIBS) GIT-LDFLAGS
3871-
$(QUIET_LINK)$(CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
3882+
$(QUIET_LINK)$(FUZZ_CXX) $(FUZZ_CXXFLAGS) -o $@ $(ALL_LDFLAGS) \
38723883
-Wl,--allow-multiple-definition \
38733884
$(filter %.o,$^) $(filter %.a,$^) $(LIBS) $(LIB_FUZZING_ENGINE)
38743885

3875-
fuzz-all: $(FUZZ_PROGRAMS)
3876-
38773886
$(UNIT_TEST_PROGS): $(UNIT_TEST_BIN)/%$X: $(UNIT_TEST_DIR)/%.o $(UNIT_TEST_DIR)/test-lib.o $(GITLIBS) GIT-LDFLAGS
38783887
$(call mkdir_p_parent_template)
38793888
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \

ci/run-build-and-minimal-fuzzers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
group "Build fuzzers" make \
99
CC=clang \
10-
CXX=clang++ \
10+
FUZZ_CXX=clang++ \
1111
CFLAGS="-fsanitize=fuzzer-no-link,address" \
1212
LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
1313
fuzz-all

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ifeq ($(uname_S),Linux)
6868
ifneq ($(findstring .el7.,$(uname_R)),)
6969
BASIC_CFLAGS += -std=c99
7070
endif
71+
LINK_FUZZ_PROGRAMS = YesPlease
7172
endif
7273
ifeq ($(uname_S),GNU/kFreeBSD)
7374
HAVE_ALLOCA_H = YesPlease

0 commit comments

Comments
 (0)