[ossfuzz] Fix parallel builds

With `make -j` multiple builds of `standaloneengine.o` happened in
parallel. Fix this by detecting `standaloneengine.o` and moving it to a
depedency.
This commit is contained in:
Nick Terrell 2020-11-05 10:27:43 -08:00
parent 664427aa8f
commit 073fe18edf

View File

@ -26,7 +26,7 @@
# ########################################################################## # ##########################################################################
LZ4DIR := ../lib LZ4DIR := ../lib
LIB_FUZZING_ENGINE ?= standaloneengine.o LIB_FUZZING_ENGINE ?=
DEBUGLEVEL?= 1 DEBUGLEVEL?= 1
DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL) DEBUGFLAGS = -g -DLZ4_DEBUG=$(DEBUGLEVEL)
@ -59,12 +59,12 @@ $(LZ4DIR)/liblz4.a:
$(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@ $(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) $< -o $@
# Generic rule for generating fuzzers # Generic rule for generating fuzzers
%_fuzzer: %_fuzzer.o lz4_helpers.o fuzz_data_producer.o $(LZ4DIR)/liblz4.a ifeq ($(LIB_FUZZING_ENGINE),)
# Compile the standalone code just in case. The OSS-Fuzz code might LIB_FUZZING_DEPS := standaloneengine.o
# override the LIB_FUZZING_ENGINE value to "-fsanitize=fuzzer" else
$(CC) -c $(LZ4_CFLAGS) $(LZ4_CPPFLAGS) standaloneengine.c -o standaloneengine.o LIB_FUZZING_DEPS :=
endif
# Now compile the actual fuzzer. %_fuzzer: %_fuzzer.o lz4_helpers.o fuzz_data_producer.o $(LZ4DIR)/liblz4.a $(LIB_FUZZING_DEPS)
$(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT) $(CXX) $(LZ4_CXXFLAGS) $(LZ4_CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT)
%_fuzzer_clean: %_fuzzer_clean: