Skip to content

Commit

Permalink
Add sanitizer builds
Browse files Browse the repository at this point in the history
  • Loading branch information
tfc committed Oct 25, 2023
1 parent 303f62e commit 6a181de
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
coverage
;

clang = config.packages.attoparsec.override {
stdenv = pkgs.clangStdenv;
};

pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
Expand All @@ -48,7 +44,28 @@
statix.enable = true;
};
};
} // pkgs.lib.optionalAttrs (!pkgs.hostPlatform.isDarwin) {

clang = config.packages.attoparsec.override {
stdenv = pkgs.clangStdenv;
};
} // (
let
sansStr = pkgs.lib.concatMapStringsSep " " (x: "-fsanitize=${x}");
toSanitized = _: sans: config.packages.attoparsec.overrideAttrs (_: {
hardeningDisable = [ "all" ];
cmakeBuildType = "Debug";
preConfigure = ''
cmakeFlagsArray+=(
"-DCMAKE_CXX_FLAGS='-fsanitize=undefined ${sansStr sans}'"
)
'';
});
in
builtins.mapAttrs toSanitized {
sanitizer-ub-address = [ "undefined" "address" ];
sanitizer-leak = [ "leak" ];
}
) // pkgs.lib.optionalAttrs (!pkgs.hostPlatform.isDarwin) {
gcc = config.packages.attoparsec.override {
stdenv = pkgs.gccStdenv;
};
Expand Down

0 comments on commit 6a181de

Please sign in to comment.