diff options
author | Felix Weilbach <felix.weilbach@nextcloud.com> | 2021-04-19 16:38:59 +0300 |
---|---|---|
committer | Felix Weilbach <felix.weilbach@nextcloud.com> | 2021-04-19 16:38:59 +0300 |
commit | 3000e2664068b2b9dbc57e3f1a53653e400593dc (patch) | |
tree | 92fa9834eccc052e8ba13d208e7dbe0bdd8ce2fc /doc | |
parent | da0b03b01c9f8dffec7383abd029b22255982a6a (diff) |
Add CMake option to enable address sanitizers
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/building.rst | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/doc/building.rst b/doc/building.rst index 31c82b737..1d7df6889 100644 --- a/doc/building.rst +++ b/doc/building.rst @@ -373,6 +373,36 @@ The following are known cmake parameters: * ``BUILD_WITH_QT4=ON``: Builds using Qt4 (even if Qt5 is found). * ``CMAKE_INSTALL_PREFIX=path``: Set an install prefix. This is mandatory on Mac OS +Address Sanitizer +================= + +You can enable the address sanitizer to detect memory corruptions and other mistakes. +The are the follwing sanitizers are available: +- Address Sanitizer (ENABLE_SANITIZER_ADDRESS) +- Leak anitizer (ENABLE_SANITIZER_LEAK) +- Memory sanitizer (ENABLE_SANITIZER_MEMORY) +- Undefined sanitizer (ENABLE_SANITIZER_UNDEFINED) +- Threads sanitizer (ENABLE_SANITIZER_THREAD) + +You can enable one or more sanitizers through CMake. For example to +enable the address and the undefined sanitizer, execute CMake like +``cmake .. -D ENABLE_SANITIZER_ADDRESS=ON -D ENABLE_SANITIZER_UNDEFINED=ON``. +Keep in mind that not all combinations of sanitizers work together and on some +platforms not all types of sanitizers are available. For example on Windows there is +currently only the address sanitizer available. If you are on Windows, you need to +make sure that the linker can find the sanitizer dlls at runtime. If you installed +Visual Studio in the standard location, you can find them in +``C:/ProgramFiles (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/x64/lib/clang/10.0.0/lib/windows``. +Make sure you add this location to your path. You may also need to +`upgrade your Visual Studio version <https://docs.microsoft.com/en-us/cpp/sanitizers/asan?view=msvc-160#install-the-addresssanitizer>`_. + +.. note:: If you use Visual Studio on Windows, you can enable the + sanitizer if you click on **Manage Configurations**, scroll + down to the section **CMake variables and cache** and then + click on the sanitizers that you want to enable. After that, + click on **Save and generate CMake cache to load variables** + right above the table. + .. _CMake: http://www.cmake.org/download .. _CSync: http://www.csync.org .. _Client Download Page: https://nextcloud.com/install/#install-clients |