Sanitizers Module

Module defining the list of supported LLVM sanitizers and exposing CMake commands to enable building ComputeAorta with them.

To access the commands and variables in this module:

include(Sanitizers)
CA_SUPPORTED_SANITIZERS

Variable storing the list of sanitizers known to work:

  • Address - Enables LLVM ASAN.

  • Thread - Enables LLVM TSAN.

  • Undefined - Enables LLVM UBSAN.

  • Fuzzer - Enables LLVM libFuzzer.

  • Address,Undefined - Enables both ASAN and UBSAN

We have additionally tested:

  • Memory - The LLVM MemorySanitizer is not yet available as LLVM requires system libraries to be built with the sanitizer.

ca_enable_sanitizer

A function verifying that a valid sanitizer is requested and checking if other internal settings, e.g. the used compiler, work with the sanitizer. Manipulation of compilation flags to enable sanitization is then performed.

LLVM accepts sanitizer settings via the CMake variable LLVM_USE_SANITIZER:STRING and only accepts sanitizer names with the first character in upper case. To simplify build scripting we also require sanitizer names to start with an upper case character, unifying sanitizer settings with LLVM. However, as ComputeAorta can be used independently from LLVM the sanitizer handling of both is independent.

Using a function for sanitizer setup limits the scope of helper variables, however we set the following variables in parent scope if required:

The function sets the following cached variable if a sanitizer is used:

  • LLVM_USE_SANITIZER - Exports the sanitizer settings to LLVM

Arguments:

Note

The root oneAPI Construction Kit CMakeLists.txt uses ca_option() to create the variable CA_USE_SANITIZER. If set by the user, this variable is used as an argument to ca_enable_sanitizer().