Sanitizer support

    An easy solution is to have an dedicated build folder for providing a matching toolchain, by building with BUILD_LLVM_CLANG=1. You can then refer to this toolchain from another build folder by specifying USECLANG=1 while overriding the CC and CXX variables.

    To use one of of the sanitizers set SANITIZE=1 and then the appropriate flag for the sanitizer you want to use.

    (or put these into your Make.user, so you don’t need to remember them every time).

    For detecting or debugging memory bugs, you can use Clang’s . By compiling with SANITIZE_ADDRESS=1 you enable ASAN for the Julia compiler and its generated code. In addition, you can specify LLVM_SANITIZE=1 to sanitize the LLVM library as well. Note that these options incur a high performance and memory cost. For example, using ASAN for Julia and LLVM makes testall1 takes 8-10 times as long while using 20 times as much memory (this can be reduced to respectively a factor of 3 and 4 by using the options described below).

    For detecting use of uninitialized memory, you can use Clang’s memory sanitizer (MSAN) by compiling with SANITIZE_MEMORY=1.

    For debugging data-races and other threading related issues you can use Clang’s by compiling with SANITIZE_THREAD=1.