build!: rename sanitizer options from CLANG_* to ENABLE_*

This commit is contained in:
ii14 2023-03-16 19:24:04 +01:00
parent 5bad9afed2
commit 17ce634b8f
8 changed files with 24 additions and 24 deletions

View File

@ -132,11 +132,11 @@ jobs:
- flavor: asan
cc: clang
runner: ubuntu-22.04
flags: -D CLANG_ASAN_UBSAN=ON
flags: -D ENABLE_ASAN_UBSAN=ON
- flavor: tsan
cc: clang
runner: ubuntu-22.04
flags: -D CLANG_TSAN=ON
flags: -D ENABLE_TSAN=ON
- flavor: uchar
cc: gcc
runner: ubuntu-22.04

View File

@ -135,18 +135,18 @@ endif()
option(LOG_LIST_ACTIONS "Add list actions logging" OFF)
option(CLANG_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
option(ENABLE_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
option(LOG_DEBUG "Enable debug log messages even in a release build" OFF)
option(CLANG_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
option(CLANG_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
option(ENABLE_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
option(ENABLE_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
if((CLANG_ASAN_UBSAN AND CLANG_MSAN)
OR (CLANG_ASAN_UBSAN AND CLANG_TSAN)
OR (CLANG_MSAN AND CLANG_TSAN))
if((ENABLE_ASAN_UBSAN AND ENABLE_MSAN)
OR (ENABLE_ASAN_UBSAN AND ENABLE_TSAN)
OR (ENABLE_MSAN AND ENABLE_TSAN))
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously")
endif()
if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
if(ENABLE_ASAN_UBSAN OR ENABLE_MSAN OR ENABLE_TSAN)
if(NOT CMAKE_C_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_C_COMPILER_ID MATCHES "GNU")
message(FATAL_ERROR "Sanitizers are only supported for Clang and GCC")
endif()

View File

@ -124,7 +124,7 @@ Each pull request must pass the automated builds on [Cirrus CI] and [GitHub Acti
- If any tests fail, the build will fail. See [test/README.md#running-tests][run-tests] to run tests locally.
- CI runs [ASan] and other analyzers.
- To run valgrind locally: `VALGRIND=1 make test`
- To run Clang ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DCLANG_ASAN_UBSAN=ON"`
- To run Clang ASan/UBSan locally: `CC=clang make CMAKE_FLAGS="-DENABLE_ASAN_UBSAN=ON"`
- The [lint](#lint) build checks modified lines _and their immediate
neighbors_, to encourage incrementally updating the legacy style to meet our
[style](#style). (See [#3174][3174] for background.)
@ -183,7 +183,7 @@ master build. To view the defects, just request access; you will be approved.
- To build Neovim with sanitizers enabled, use
```
rm -rf build && CMAKE_EXTRA_FLAGS="-DCMAKE_C_COMPILER=clang -DCLANG_ASAN_UBSAN=1" make
rm -rf build && CMAKE_EXTRA_FLAGS="-DCMAKE_C_COMPILER=clang -DENABLE_ASAN_UBSAN=1" make
```
- When running Neovim, use
```
@ -294,7 +294,7 @@ If a function in your Lua module should not be documented (e.g. internal functio
---@private
```
Mark functions that are deprecated as
Mark functions that are deprecated as
```
---@deprecated
```

View File

@ -19,7 +19,7 @@ endif()
set(LUA_CFLAGS "-O0 -g3 -fPIC")
set(LUA_LDFLAGS "")
if(CLANG_ASAN_UBSAN)
if(ENABLE_ASAN_UBSAN)
set(LUA_CFLAGS "${LUA_CFLAGS} -fsanitize=address")
set(LUA_CFLAGS "${LUA_CFLAGS} -fno-omit-frame-pointer")
set(LUA_CFLAGS "${LUA_CFLAGS} -fno-optimize-sibling-calls")

View File

@ -16,7 +16,7 @@ export ASAN_OPTIONS="detect_leaks=0:log_path=$log_path/asan"
# Show backtraces in the logs.
export UBSAN_OPTIONS="print_stacktrace=1"
make -C "$root_path" CMAKE_EXTRA_FLAGS="-DCLANG_ASAN_UBSAN=ON"
make -C "$root_path" CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim
# Need to manually reset terminal to avoid mangled output, nvim does not

View File

@ -48,7 +48,7 @@
] ++ final.lib.optionals final.stdenv.isLinux [
# https://github.com/google/sanitizers/wiki/AddressSanitizerFlags
# https://clang.llvm.org/docs/AddressSanitizer.html#symbolizing-the-reports
"-DCLANG_ASAN_UBSAN=ON"
"-DENABLE_ASAN_UBSAN=ON"
];
});
};

View File

@ -200,9 +200,9 @@ endif()
option(ENABLE_GCOV "Enable gcov support" OFF)
if(ENABLE_GCOV)
if(CLANG_TSAN)
if(ENABLE_TSAN)
# GCOV and TSAN results in false data race reports
message(FATAL_ERROR "ENABLE_GCOV cannot be used with CLANG_TSAN")
message(FATAL_ERROR "ENABLE_GCOV cannot be used with ENABLE_TSAN")
endif()
message(STATUS "Enabling gcov support")
target_compile_options(main_lib INTERFACE --coverage)
@ -378,7 +378,7 @@ else()
target_compile_definitions(nvim PRIVATE $<$<CONFIG:Debug>:NVIM_LOG_DEBUG>)
endif()
if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
if(ENABLE_ASAN_UBSAN OR ENABLE_MSAN OR ENABLE_TSAN)
target_compile_definitions(main_lib INTERFACE EXITFREE)
endif()
@ -791,7 +791,7 @@ set_target_properties(
target_compile_definitions(libnvim PRIVATE MAKE_LIB)
target_link_libraries(libnvim PRIVATE main_lib PUBLIC libuv)
if(CLANG_ASAN_UBSAN)
if(ENABLE_ASAN_UBSAN)
message(STATUS "Enabling Clang address sanitizer and undefined behavior sanitizer for nvim.")
if(CI_BUILD)
# Try to recover from all sanitize issues so we get reports about all failures
@ -805,7 +805,7 @@ if(CLANG_ASAN_UBSAN)
-fsanitize=address
-fsanitize=undefined)
target_link_libraries(nvim PRIVATE -fsanitize=address -fsanitize=undefined)
elseif(CLANG_MSAN)
elseif(ENABLE_MSAN)
message(STATUS "Enabling Clang memory sanitizer for nvim.")
target_compile_options(nvim PRIVATE
-fsanitize=memory
@ -813,7 +813,7 @@ elseif(CLANG_MSAN)
-fno-omit-frame-pointer
-fno-optimize-sibling-calls)
target_link_libraries(nvim PRIVATE -fsanitize=memory -fsanitize-memory-track-origins)
elseif(CLANG_TSAN)
elseif(ENABLE_TSAN)
message(STATUS "Enabling Clang thread sanitizer for nvim.")
target_compile_options(nvim PRIVATE -fsanitize=thread -fPIE)
target_link_libraries(nvim PRIVATE -fsanitize=thread)

View File

@ -60,9 +60,9 @@ Requires clang 3.4 or later, and `llvm-symbolizer` must be in `$PATH`:
Build Nvim with sanitizer instrumentation (choose one):
CC=clang make CMAKE_EXTRA_FLAGS="-DCLANG_ASAN_UBSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DCLANG_MSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DCLANG_TSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_ASAN_UBSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_MSAN=ON"
CC=clang make CMAKE_EXTRA_FLAGS="-DENABLE_TSAN=ON"
Create a directory to store logs: