From 02b5b3c242fd4131983152f0dd422429e6702923 Mon Sep 17 00:00:00 2001 From: Max Dymond Date: Fri, 28 Jun 2019 23:48:33 +0100 Subject: [PATCH] Move to using C rather than C++ for compilation --- Makefile | 1 + ossfuzz/Makefile | 12 +++++++++--- ossfuzz/{compress_fuzzer.cc => compress_fuzzer.c} | 2 +- ossfuzz/{decompress_fuzzer.cc => decompress_fuzzer.c} | 2 +- ossfuzz/{standaloneengine.cc => standaloneengine.c} | 0 ossfuzz/testinput.h | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) rename ossfuzz/{compress_fuzzer.cc => compress_fuzzer.c} (89%) rename ossfuzz/{decompress_fuzzer.cc => decompress_fuzzer.c} (89%) rename ossfuzz/{standaloneengine.cc => standaloneengine.c} (100%) diff --git a/Makefile b/Makefile index 34835fd..f25f951 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,7 @@ clean: @$(MAKE) -C $(PRGDIR) $@ > $(VOID) @$(MAKE) -C $(TESTDIR) $@ > $(VOID) @$(MAKE) -C $(EXDIR) $@ > $(VOID) + @$(MAKE) -C $(FUZZDIR) $@ > $(VOID) @$(MAKE) -C contrib/gen_manual $@ > $(VOID) @$(RM) lz4$(EXT) @echo Cleaning completed diff --git a/ossfuzz/Makefile b/ossfuzz/Makefile index 1e7679b..1480ccb 100644 --- a/ossfuzz/Makefile +++ b/ossfuzz/Makefile @@ -42,14 +42,20 @@ include ../Makefile.inc $(LZ4DIR)/liblz4.a: $(MAKE) -C $(LZ4DIR) CFLAGS="$(CFLAGS)" liblz4.a -%.o: %.cc - $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@ +%.o: %.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ # Generic rule for generating fuzzers %_fuzzer: %_fuzzer.o $(LZ4DIR)/liblz4.a # Compile the standalone code just in case. The OSS-Fuzz code might # override the LIB_FUZZING_ENGINE value to "-fsanitize=fuzzer" - $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) standaloneengine.cc -o standaloneengine.o + $(CC) -c $(CFLAGS) $(CPPFLAGS) standaloneengine.c -o standaloneengine.o # Now compile the actual fuzzer. $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIB_FUZZING_ENGINE) $^ -o $@$(EXT) + +%_fuzzer_clean: + $(RM) $*_fuzzer $*_fuzzer.o standaloneengine.o + +.PHONY: clean +clean: compress_fuzzer_clean decompress_fuzzer_clean diff --git a/ossfuzz/compress_fuzzer.cc b/ossfuzz/compress_fuzzer.c similarity index 89% rename from ossfuzz/compress_fuzzer.cc rename to ossfuzz/compress_fuzzer.c index 4a720e2..28610ad 100644 --- a/ossfuzz/compress_fuzzer.cc +++ b/ossfuzz/compress_fuzzer.c @@ -5,7 +5,7 @@ #define CHECK(COND) if (!(COND)) { abort(); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { size_t const compressed_dest_size = LZ4_compressBound(size); char *const dest_buffer = (char *)malloc(compressed_dest_size); diff --git a/ossfuzz/decompress_fuzzer.cc b/ossfuzz/decompress_fuzzer.c similarity index 89% rename from ossfuzz/decompress_fuzzer.cc rename to ossfuzz/decompress_fuzzer.c index 594a5af..1fa2b1a 100644 --- a/ossfuzz/decompress_fuzzer.cc +++ b/ossfuzz/decompress_fuzzer.c @@ -5,7 +5,7 @@ #define CHECK(COND) if (!(COND)) { abort(); } -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { size_t const buffer_size = 10 * 1024 * 1024; char *const dest_buffer = (char *)malloc(buffer_size); diff --git a/ossfuzz/standaloneengine.cc b/ossfuzz/standaloneengine.c similarity index 100% rename from ossfuzz/standaloneengine.cc rename to ossfuzz/standaloneengine.c diff --git a/ossfuzz/testinput.h b/ossfuzz/testinput.h index 6ab9b51..8da6215 100644 --- a/ossfuzz/testinput.h +++ b/ossfuzz/testinput.h @@ -1,3 +1,3 @@ #include -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); -- 2.7.4