diff --git a/docs/Development-Guide.rst b/docs/Development-Guide.rst index ec8e1a7003b7..c8b30173da79 100644 --- a/docs/Development-Guide.rst +++ b/docs/Development-Guide.rst @@ -80,6 +80,7 @@ Tests C++ unit tests are located in the ``./tests/cpp_tests`` folder and written with the help of Google Test framework. To run tests locally first refer to the `Installation Guide <./Installation-Guide.rst#build-c-unit-tests>`__ for how to build tests and then simply run compiled executable file. +It is highly recommended to build tests with `sanitizers <./Installation-Guide.rst#sanitizers>`__. High Level Language Package --------------------------- diff --git a/docs/Installation-Guide.rst b/docs/Installation-Guide.rst index 71182710f140..bb45ec42c7a4 100644 --- a/docs/Installation-Guide.rst +++ b/docs/Installation-Guide.rst @@ -13,6 +13,21 @@ Users who want to perform benchmarking can make LightGBM output time costs for d It is possible to build LightGBM in debug mode. In this mode all compiler optimizations are disabled and LightGBM performs more checks internally. To enable debug mode you can add ``-DUSE_DEBUG=ON`` to CMake flags or choose ``Debug_*`` configuration (e.g. ``Debug_DLL``, ``Debug_mpi``) in Visual Studio depending on how you are building LightGBM. +.. _sanitizers: + +In addition to the debug mode, LightGBM can be built with compiler sanitizers. +To enable them add ``-DUSE_SANITIZER=ON -DENABLED_SANITIZERS="address;leak;undefined"`` to CMake flags. +These values refer to the following supported sanitizers: + +- ``address`` - AddressSanitizer (ASan); +- ``leak`` - LeakSanitizer (LSan); +- ``undefined`` - UndefinedBehaviorSanitizer (UBSan); +- ``thread`` - ThreadSanitizer (TSan). + +Please note, that ThreadSanitizer cannot be used together with other sanitizers. +For more info and additional sanitizers' parameters please refer to the `following docs`_. +It is very useful to build `C++ unit tests <#build-c-unit-tests>`__ with sanitizers. + .. _nightly-builds: You can also download the artifacts of the latest successful build on master branch (nightly builds) here: |download artifacts|. @@ -914,3 +929,5 @@ gcc .. _SWIG: http://www.swig.org/download.html .. _this detailed guide: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html + +.. _following docs: https://github.com/google/sanitizers/wiki