File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -579,12 +579,32 @@ if(UMF_USE_MSAN)
579579 "prevent reporting false-positives" )
580580 add_sanitizer_flag(memory)
581581endif ()
582+
582583# Fuzzer instrumentation for the whole library
583584if (UMF_BUILD_FUZZTESTS
584585 AND CMAKE_CXX_COMPILER_ID MATCHES "Clang"
585586 AND LINUX)
586587 add_compile_options ("-fsanitize=fuzzer-no-link" )
587588 add_link_options ("-fsanitize=fuzzer-no-link" )
589+
590+ # We need to find the fuzzer lib in the LLVM installation dir and link it
591+ # statically
592+ string (REGEX MATCH "^[0-9]+" CMAKE_C_COMPILER_MAJOR_VERSION
593+ ${CMAKE_C_COMPILER_VERSION} )
594+ find_library (
595+ FUZZER_NO_MAIN_LIB
596+ NAMES libclang_rt.fuzzer_no_main-x86_64.a
597+ PATHS
598+ "/usr/lib/llvm-${CMAKE_C_COMPILER_MAJOR_VERSION} /lib/clang/${CMAKE_C_COMPILER_MAJOR_VERSION} /lib/linux/"
599+ )
600+
601+ if (FUZZER_NO_MAIN_LIB)
602+ message (STATUS "Found fuzzer lib: ${FUZZER_NO_MAIN_LIB} " )
603+ # Fuzzer lib requires libstdc++
604+ link_libraries (${FUZZER_NO_MAIN_LIB} "stdc++" )
605+ else ()
606+ message (FATAL_ERROR "libclang_rt.fuzzer_no_main-x86_64 not found!" )
607+ endif ()
588608endif ()
589609
590610# A header-only lib to specify include directories in transitive dependencies
You can’t perform that action at this time.
0 commit comments