Move to using C rather than C++ for compilation
authorMax Dymond <cmeister2@gmail.com>
Fri, 28 Jun 2019 22:48:33 +0000 (23:48 +0100)
committerMax Dymond <cmeister2@gmail.com>
Fri, 28 Jun 2019 22:48:33 +0000 (23:48 +0100)
Makefile
ossfuzz/Makefile
ossfuzz/compress_fuzzer.c [moved from ossfuzz/compress_fuzzer.cc with 89% similarity]
ossfuzz/decompress_fuzzer.c [moved from ossfuzz/decompress_fuzzer.cc with 89% similarity]
ossfuzz/standaloneengine.c [moved from ossfuzz/standaloneengine.cc with 100% similarity]
ossfuzz/testinput.h

index 34835fd..f25f951 100644 (file)
--- 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
index 1e7679b..1480ccb 100644 (file)
@@ -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
similarity index 89%
rename from ossfuzz/compress_fuzzer.cc
rename to ossfuzz/compress_fuzzer.c
index 4a720e2..28610ad 100644 (file)
@@ -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);
similarity index 89%
rename from ossfuzz/decompress_fuzzer.cc
rename to ossfuzz/decompress_fuzzer.c
index 594a5af..1fa2b1a 100644 (file)
@@ -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);
index 6ab9b51..8da6215 100644 (file)
@@ -1,3 +1,3 @@
 #include <inttypes.h>
 
-extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);