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 ${CMAKE_C_COMPILER_VERSION} )
593+ find_library (
594+ FUZZER_NO_MAIN_LIB
595+ NAMES libclang_rt.fuzzer_no_main-x86_64.a
596+ PATHS
597+ "/usr/lib/llvm-${CMAKE_C_COMPILER_MAJOR_VERSION} /lib/clang/${CMAKE_C_COMPILER_MAJOR_VERSION} /lib/linux/"
598+ )
599+
600+ if (FUZZER_NO_MAIN_LIB)
601+ message (STATUS "Found fuzzer lib: ${FUZZER_NO_MAIN_LIB} " )
602+ # Fuzzer lib requires libstdc++
603+ link_libraries (${FUZZER_NO_MAIN_LIB} "stdc++" )
604+ else ()
605+ message (FATAL_ERROR "libclang_rt.fuzzer_no_main-x86_64 not found!" )
606+
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