Skip to content

Commit 661b67d

Browse files
committed
add required lib if UMF_BUILD_FUZZTESTS is set
1 parent 325d447 commit 661b67d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

CMakeLists.txt

+20
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,32 @@ if(UMF_USE_MSAN)
579579
"prevent reporting false-positives")
580580
add_sanitizer_flag(memory)
581581
endif()
582+
582583
# Fuzzer instrumentation for the whole library
583584
if(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()
588608
endif()
589609

590610
# A header-only lib to specify include directories in transitive dependencies

0 commit comments

Comments
 (0)