OSS-Fuzz: Build fuzz targets using C++ compiler
Otherwise, the targets will require libstdc++, the i386 version of which is not available in the OSS-Fuzz runtime environment. The OSS-Fuzz build environment passes -stdlib:libc++ in the CXXFLAGS environment variable in order to mitigate this issue, since the runtime environment has the i386 version of libc++, but using that compiler flag requires using the C++ compiler.
This commit is contained in:
@@ -16,6 +16,12 @@ if(NOT FUZZ_LIBRARY)
|
|||||||
endif()
|
endif()
|
||||||
message(STATUS "FUZZ_LIBRARY = ${FUZZ_LIBRARY}")
|
message(STATUS "FUZZ_LIBRARY = ${FUZZ_LIBRARY}")
|
||||||
|
|
||||||
|
enable_language(CXX)
|
||||||
|
|
||||||
|
set(EFFECTIVE_CXX_FLAGS
|
||||||
|
"${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
|
||||||
|
message(STATUS "C++ Compiler flags = ${EFFECTIVE_CXX_FLAGS}")
|
||||||
|
|
||||||
macro(add_fuzz_target target source_file)
|
macro(add_fuzz_target target source_file)
|
||||||
add_executable(${target}_fuzzer ${source_file})
|
add_executable(${target}_fuzzer ${source_file})
|
||||||
if(NOT ENABLE_SHARED)
|
if(NOT ENABLE_SHARED)
|
||||||
@@ -29,8 +35,8 @@ endmacro()
|
|||||||
# NOTE: This target is named libjpeg_turbo_fuzzer instead of decompress_fuzzer
|
# NOTE: This target is named libjpeg_turbo_fuzzer instead of decompress_fuzzer
|
||||||
# in order to preserve the corpora from Google's OSS-Fuzz target for
|
# in order to preserve the corpora from Google's OSS-Fuzz target for
|
||||||
# libjpeg-turbo, which this target replaces.
|
# libjpeg-turbo, which this target replaces.
|
||||||
add_fuzz_target(libjpeg_turbo decompress.c)
|
add_fuzz_target(libjpeg_turbo decompress.cc)
|
||||||
|
|
||||||
add_fuzz_target(decompress_yuv decompress_yuv.c)
|
add_fuzz_target(decompress_yuv decompress_yuv.cc)
|
||||||
|
|
||||||
add_fuzz_target(transform transform.c)
|
add_fuzz_target(transform transform.cc)
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ set -u
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
|
cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \
|
||||||
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
|
-DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \
|
||||||
|
-DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \
|
||||||
-DWITH_FUZZ=1 -DFUZZ_BINDIR=$OUT -DFUZZ_LIBRARY=$LIB_FUZZING_ENGINE
|
-DWITH_FUZZ=1 -DFUZZ_BINDIR=$OUT -DFUZZ_LIBRARY=$LIB_FUZZING_ENGINE
|
||||||
make "-j$(nproc)" "--load-average=$(nproc)"
|
make "-j$(nproc)" "--load-average=$(nproc)"
|
||||||
make install
|
make install
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
#define NUMPF 4
|
#define NUMPF 4
|
||||||
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
tjhandle handle = NULL;
|
tjhandle handle = NULL;
|
||||||
unsigned char *dstBuf = NULL;
|
unsigned char *dstBuf = NULL;
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
#define NUMPF 3
|
#define NUMPF 3
|
||||||
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
tjhandle handle = NULL;
|
tjhandle handle = NULL;
|
||||||
unsigned char *dstBuf = NULL, *yuvBuf = NULL;
|
unsigned char *dstBuf = NULL, *yuvBuf = NULL;
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
#define NUMXFORMS 3
|
#define NUMXFORMS 3
|
||||||
|
|
||||||
|
|
||||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
tjhandle handle = NULL;
|
tjhandle handle = NULL;
|
||||||
unsigned char *dstBufs[NUMXFORMS] = { NULL, NULL, NULL };
|
unsigned char *dstBufs[NUMXFORMS] = { NULL, NULL, NULL };
|
||||||
Reference in New Issue
Block a user