Add build and runtime support for gcc/clang sanitizers
Adds support in Gaudi for activating santizers via the CMTCONFIG setting.
http://clang.llvm.org/docs/AddressSanitizer.html
http://clang.llvm.org/docs/LeakSanitizer.html
http://clang.llvm.org/docs/ThreadSanitizer.html
http://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html
Uses the existing functionality to extend the type flag with subtypes. e.g.
x86_64-centos7-gcc7-dbg+asan
will activate the address sanitizer on top of the x86_64-centos7-gcc7-dbg build
The main changes are :
-
Add support for understanding four new subtypes,
asan,lsan,tsanandubsanwhich triggers the required compiler options for each to be added to the build flags. Defaults are provided but these can if required be changed via aCMakecommand line flag. -
Some runtime support is also required.
- One is to set some environment variables, like
ASAN_OPTIONSto pass runtime options to the sanitizers. Again some defaults are provided. - Some default suppression files are also provided to suppress warnings. So far I have only added a few for
lsan, but support is there for the others as well. - In order for
gaudirun.pyapplications to work, the relevant runtime library needs to be preloaded (because the binary that starts the job,python, is not built with the sanitizers). This is done by setting an environment variable whichgaudrun.pyuses to detect when a sanitizer is enabled and automatically preloads the required library.
- I also need a small patch to how
genconfis run to, when sanitizers are enabled, to prevent errors from runninggenconfitself aborting the build.
Examples of the results, for a sub-set of LHCb QM tests are at
https://www.hep.phy.cam.ac.uk/~jonesc/lhcb/QMTests/Saved/Sanitizers