Skip to content

Commit d5e8438

Browse files
committed
doc: Document building with sanitizers
1 parent 94d37e6 commit d5e8438

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

doc/manual/source/development/debugging.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ It is also possible to build without debugging for faster build:
2424

2525
(The first line is needed because `fortify` hardening requires at least some optimization.)
2626

27+
## Building Nix with sanitizers
28+
29+
Nix can be built with [Address](https://clang.llvm.org/docs/AddressSanitizer.html) and
30+
[UB](https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html) sanitizers using LLVM
31+
or GCC. This is useful when debugging memory corruption issues.
32+
33+
```console
34+
[nix-shell]$ export mesonBuildType=debugoptimized
35+
[nix-shell]$ appendToVar mesonFlags "-Dlibexpr:gc=disabled" # Disable Boehm
36+
[nix-shell]$ appendToVar mesonFlags "-Dbindings=false" # Disable nix-perl
37+
[nix-shell]$ appendToVar mesonFlags "-Db_sanitize=address,undefined"
38+
```
39+
2740
## Debugging the Nix Binary
2841

2942
Obtain your preferred debugger within the development shell:

0 commit comments

Comments
 (0)