Skip to content

Commit 0bbd51c

Browse files
committed
a
1 parent 97d5697 commit 0bbd51c

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

.github/workflows/nightly.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,16 @@ jobs:
3636
sudo apt-get update
3737
sudo apt-get install -y cmake hwloc libhwloc-dev libnuma-dev libtbb-dev
3838
39+
- name: Find Clan fuzzer lib
40+
run: |
41+
CLANG_LIBS_DIR=$(find /usr/lib -name "libclang_rt.fuzzer_no_main*.*" -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}}

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,14 +588,11 @@ if(UMF_BUILD_FUZZTESTS
588588
add_link_options("-fsanitize=fuzzer-no-link")
589589

590590
# 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})
591+
# statically as UMF does not define the main function used by fuzzer as
592+
# well as __sancov_* functions
594593
find_library(
595594
FUZZER_NO_MAIN_LIB
596595
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/"
599596
)
600597

601598
if(FUZZER_NO_MAIN_LIB)

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ List of sanitizers available on Windows:
9797

9898
Listed 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`. Additionally, ensure that the `CMAKE_PREFIX_PATH` includes the
104+
directory containing the Clang libraries required for fuzzing.
105+
106+
Example:
107+
108+
```bash
109+
cmake -B build -DCMAKE_BUILD_TYPE=Debug -DUMF_BUILD_FUZZTESTS=ON -DCMAKE_PREFIX_PATH=/path/to/clang/libs
110+
```
111+
100112
### CMake standard options
101113

102114
List of options provided by CMake:

0 commit comments

Comments
 (0)