File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -36,13 +36,20 @@ jobs:
3636 sudo apt-get update
3737 sudo apt-get install -y cmake hwloc libhwloc-dev libnuma-dev libtbb-dev
3838
39+ - name : Find Clang fuzzer lib
40+ run : |
41+ CLANG_LIBS_DIR=$(find /usr/lib -name "libclang_rt.fuzzer_no_main-x86_64.a" -exec dirname {} \; | head -n 1)
42+ echo "CLANG_LIBS_DIR=${CLANG_LIBS_DIR}" >> $GITHUB_ENV
43+
3944 - name : Configure CMake
4045 run : >
4146 cmake
4247 -B ${{github.workspace}}/build
48+ -DCMAKE_PREFIX_PATH=${{env.CLANG_LIBS_DIR}}
4349 -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
4450 -DCMAKE_C_COMPILER=${{matrix.compiler.c}}
4551 -DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
52+ -DUMF_BUILD_SHARED_LIBRARY=ON
4653 -DUMF_TESTS_FAIL_ON_SKIP=ON
4754 -DUMF_DEVELOPER_MODE=ON
4855 -DUMF_BUILD_FUZZTESTS=ON
Original file line number Diff line number Diff line change @@ -579,12 +579,26 @@ 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 as UMF does not define the main function used by fuzzer as well
592+ # as __sancov_* functions
593+ find_library (FUZZER_NO_MAIN_LIB NAMES libclang_rt.fuzzer_no_main-x86_64.a)
594+
595+ if (FUZZER_NO_MAIN_LIB)
596+ message (STATUS "Found fuzzer lib: ${FUZZER_NO_MAIN_LIB} " )
597+ # Fuzzer lib requires libstdc++
598+ link_libraries (${FUZZER_NO_MAIN_LIB} "stdc++" )
599+ else ()
600+ message (FATAL_ERROR "libclang_rt.fuzzer_no_main-x86_64 not found!" )
601+ endif ()
588602endif ()
589603
590604# A header-only lib to specify include directories in transitive dependencies
Original file line number Diff line number Diff line change @@ -97,6 +97,19 @@ List of sanitizers available on Windows:
9797
9898Listed sanitizers can be enabled with appropriate [ CMake options] ( #cmake-standard-options ) .
9999
100+ ### Fuzz testing
101+
102+ To enable fuzz testing, the ` UMF_BUILD_FUZZTESTS ` CMake configuration flag must
103+ be set to ` ON ` . Note, that this feature is supported only on Linux and requires
104+ Clang. Additionally, ensure that the ` CMAKE_PREFIX_PATH ` includes the directory
105+ containing the Clang libraries necessary for fuzzing.
106+
107+ Example:
108+
109+ ``` bash
110+ cmake -B build -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Debug -DUMF_BUILD_FUZZTESTS=ON -DCMAKE_PREFIX_PATH=/path/to/clang/libs
111+ ```
112+
100113### CMake standard options
101114
102115List of options provided by CMake:
You can’t perform that action at this time.
0 commit comments