mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 13:17:35 +00:00
Lagom: Various fixes to make Lagom run on OSS-Fuzz (#4176)
This commit is contained in:
parent
83f6b8bc9a
commit
ff8ac60184
3 changed files with 72 additions and 52 deletions
|
@ -47,6 +47,9 @@ inline void fill_with_random(void* buffer, size_t length)
|
|||
{
|
||||
#if defined(__serenity__)
|
||||
arc4random_buf(buffer, length);
|
||||
#elif defined(OSS_FUZZ)
|
||||
(void)buffer;
|
||||
(void)length;
|
||||
#elif defined(__unix__) or defined(__APPLE__)
|
||||
int rc = getentropy(buffer, length);
|
||||
(void)rc;
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
cmake_minimum_required (VERSION 3.0)
|
||||
project (Lagom)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -O2 -Wall -Wextra -Werror -std=c++2a -fPIC -g -Wno-deprecated-copy")
|
||||
if (NOT ENABLE_OSS_FUZZ)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -O2 -Wall -Wextra -Werror -std=c++2a -fPIC -g -Wno-deprecated-copy")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++2a -fPIC -g -Wno-deprecated-copy")
|
||||
endif()
|
||||
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconsumed -Wno-overloaded-virtual")
|
||||
|
@ -68,9 +73,12 @@ include_directories (../../)
|
|||
include_directories (../../Libraries/)
|
||||
add_library(LagomCore ${LAGOM_CORE_SOURCES})
|
||||
|
||||
|
||||
|
||||
if (BUILD_LAGOM)
|
||||
add_library(Lagom $<TARGET_OBJECTS:LagomCore> ${LAGOM_MORE_SOURCES})
|
||||
|
||||
if (NOT ENABLE_OSS_FUZZ)
|
||||
add_executable(TestApp TestApp.cpp)
|
||||
target_link_libraries(TestApp Lagom)
|
||||
target_link_libraries(TestApp stdc++)
|
||||
|
@ -127,8 +135,9 @@ if (BUILD_LAGOM)
|
|||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ENABLE_FUZZER_SANITIZER)
|
||||
if (ENABLE_FUZZER_SANITIZER OR ENABLE_OSS_FUZZ)
|
||||
add_subdirectory(Fuzzers)
|
||||
endif()
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
function(add_simple_fuzzer name)
|
||||
add_executable(${name} "${name}.cpp")
|
||||
|
||||
if (ENABLE_OSS_FUZZ)
|
||||
target_link_libraries(${name}
|
||||
PUBLIC Lagom)
|
||||
else()
|
||||
target_compile_options(${name}
|
||||
PRIVATE $<$<C_COMPILER_ID:Clang>:-g -O1 -fsanitize=fuzzer>
|
||||
)
|
||||
|
@ -7,6 +12,7 @@ function(add_simple_fuzzer name)
|
|||
PUBLIC Lagom
|
||||
PRIVATE $<$<C_COMPILER_ID:Clang>:-fsanitize=fuzzer>
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_simple_fuzzer(FuzzBMPLoader)
|
||||
|
@ -22,6 +28,7 @@ add_simple_fuzzer(FuzzPPMLoader)
|
|||
add_simple_fuzzer(FuzzJs)
|
||||
add_simple_fuzzer(FuzzMarkdown)
|
||||
|
||||
if (NOT ENABLE_OSS_FUZZ)
|
||||
add_executable(FuzzilliJs FuzzilliJs.cpp)
|
||||
target_compile_options(FuzzilliJs
|
||||
PRIVATE $<$<C_COMPILER_ID:Clang>:-g -O1 -fsanitize-coverage=trace-pc-guard>
|
||||
|
@ -30,3 +37,4 @@ target_link_libraries(FuzzilliJs
|
|||
PUBLIC Lagom
|
||||
PRIVATE $<$<C_COMPILER_ID:Clang>:-fsanitize-coverage=trace-pc-guard>
|
||||
)
|
||||
endif()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue