Skip to content

Commit

Permalink
add clang-sanitizers for crypto 3
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMlashkin committed Sep 17, 2024
1 parent 10aa6a9 commit 865de58
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crypto3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ option(Boost_USE_STATIC_LIBS "Use static libraries for Boost" OFF)
option(CMAKE_ENABLE_TESTS "Enable tests" FALSE) # used by CMTest module
option(BUILD_BENCH_TESTS "Build performance benchmark tests" FALSE)
option(BUILD_DOCS "Build with configuring Doxygen documentation compiler" FALSE)
option(SANITIZE "Build sanitizers" FALSE)

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "-ggdb -O0")
endif()

if(${SANITIZE})
add_compile_options(-fsanitize=undefined,address,leak)
add_link_options(-fsanitize=undefined,address,leak)
endif()

# This is useful due to some build systems (Ninja in particular) are piping
# compiler output and compiler switches it's output to plain text
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
Expand Down
2 changes: 2 additions & 0 deletions crypto3/crypto3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
enableDebugging,
enableDebug ? false,
runTests ? false,
sanitize ? false,
}:
let
inherit (lib) optional;
Expand All @@ -28,6 +29,7 @@ in stdenv.mkDerivation {
[
(if runTests then "-DBUILD_TESTS=TRUE" else "-DBUILD_TESTS=False")
(if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release")
(if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF")
"-G Ninja"
];

Expand Down
7 changes: 7 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
crypto3-debug-tests = (pkgs.callPackage ./crypto3/crypto3.nix {
enableDebug = true;
runTests = true;
sanitize = true;
});

parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix {
Expand Down Expand Up @@ -145,6 +146,12 @@
runTests = true;
enableDebug = false;
});
crypto3-clang-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix {
stdenv = pkgs.llvmPackages_18.stdenv;
runTests = true;
enableDebug = false;
sanitize = true;
});

parallel-crypto3-gcc = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix {
runTests = true;
Expand Down

0 comments on commit 865de58

Please sign in to comment.