Skip to content

Commit

Permalink
[build] Improve error on sanitizer check failure
Browse files Browse the repository at this point in the history
Suggest that a possible reason for failure is that the user is not using
clang.

Test plan:
```
cmake .. -GNinja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DENABLE_SANITIZERS=fuzzer # observe new error message
rm -rf *
cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_SANITIZERS=fuzzer # No error
```
  • Loading branch information
dagurval committed Jul 2, 2020
1 parent 380d1e6 commit e92388e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmake/modules/Sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function(enable_sanitizers)
set(CMAKE_EXE_LINKER_FLAGS ${_save_linker_flags})

if(NOT ${_sanitizers_compile})
if (NOT ((${CMAKE_C_COMPILER} MATCHES ".*clang.*") AND (${CMAKE_CXX_COMPILER} MATCHES ".*clang.*")))
message(STATUS "
Check for sanitizer support failed. A common error is not setting \
C/C++ compiler to 'clang' when using libFuzzer. See\n \
https://docs.bitcoincashnode.org/doc/fuzzing/")
endif()
message(FATAL_ERROR "The sanitizers option is not supported: ${_fsanitize_option}")
endif()

Expand Down

0 comments on commit e92388e

Please sign in to comment.