mariadb/cmake
Marko Mäkelä 68e6c2d768 MDEV-20377: Introduce cmake -DWITH_MSAN:BOOL=ON
MemorySanitizer is a compile-time instrumentation layer in clang and GCC.
Together with AddressSanitizer mostly makes the run-time instrumentation
of Valgrind redundant. It is a little more tricky to set up, because
running with uninstrumented libraries will lead into false positives.

You will need an instrumented libc++, and you should use
-stdlib=libc++ instead of the default libstdc++. To build the
instrumented library, you can refer to
https://github.com/google/sanitizers/wiki/MemorySanitizerLibcxxHowTo
or you can adapt these steps that worked for me, for clang-8 version 8.0.1:

cd /mariadb
sudo apt source libc++-8-dev
cd llvm-toolchain-8-8.0.1
mkdir libc++msan; cd libc++msan
cmake ../libcxx -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_SANITIZER=Memory \
-DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8

Then, in your MariaDB build directory, you have to compile with
libc++ and bundled libraries, such as WITH_SSL=bundled, WITH_ZLIB=bundled.
For uninstrumented system libraries, you will get false positives for
uninitialized values. Like this:

cmake -DWITH_MSAN=ON -DWITH_SSL=bundled -DWITH_ZLIB=bundled \
-DCMAKE_CXX_FLAGS='-stdlib=libc++' ..

Note: you should also add -O2 to the compiler options, or you may
get crashes due to stack overflow.

Finally, to run tests, you must replace libc++ with the instrumented one:

LD_LIBRARY_PATH=/mariadb/llvm-toolchain-8-8.0.1/libc++msan/lib \
MSAN_OPTIONS=abort_on_error=1 \
./mtr --big-test --parallel=auto --force --retry=0

Failure to do so will report numerous false positives related to
operations on std::string and the like.

This is work in progress. Some issues will still have to be fixed
for WITH_MSAN to be usable. See MDEV-20377 for details.
2019-08-19 20:56:26 +03:00
..
build_configurations Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Internal/CPack cmake 3.14 2019-03-23 14:33:36 +01:00
os Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
abi_check.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
bison.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
build_depends.cmake cmake: force Boost dependency as needed 2019-04-08 17:27:25 +02:00
character_sets.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
check_compiler_flag.cmake Merge 10.1 into 10.2 2019-06-12 10:30:01 +03:00
compile_flags.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
configurable_file_content.in Updated/added copyright headers 2011-06-30 17:46:53 +02:00
configure.pl Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
cpack_deb.cmake simplify CMakeLists.txt for cassandra/connect engines 2013-09-25 19:32:14 +02:00
cpack_rpm.cmake cleanup: CPACK_RPM_* package description 2019-07-10 09:02:10 +02:00
cpack_source_ignore_files.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
cpu_info.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
crc32-vpmsum.cmake MDEV-9872 - Add common optimized CRC32 function interface 2016-08-04 10:45:20 +04:00
create_initial_db.cmake.in Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
ctest.cmake Revert "MDEV-16075: Workaround to run MTR test suite for make test" 2018-06-20 23:27:23 +02:00
do_abi_check.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
dtrace.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
dtrace_prelink.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
FindJava.cmake make CONNECT's finding Java and JNI less verbose 2016-09-12 17:46:35 +02:00
FindJNI.cmake copy-paste error fixed 2016-09-22 13:07:38 +02:00
FindLZ4.cmake RocksDB : Add lookup / compiling with optional compression libraries. 2017-02-09 16:55:02 +00:00
FindZSTD.cmake RocksDB : Add lookup / compiling with optional compression libraries. 2017-02-09 16:55:02 +00:00
for_clients.cmake MDEV-12938 Discrepancy between mysql_config and mariadb_config 2017-07-05 17:15:59 +02:00
info_bin.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
info_macros.cmake.in Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
info_src.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
install_layout.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
install_macros.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
jemalloc.cmake Merge branch '10.0' into 10.1 2016-02-23 21:35:05 +01:00
libutils.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
maintainer.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
make_dist.cmake.in Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
mariadb_connector_c.cmake post-merge: -Werror fixes in 10.2 2019-03-29 10:58:25 +01:00
merge_archives_unix.cmake.in Update FSF Address 2019-05-11 21:29:06 +03:00
misc.cmake cleanup: CPACK_RPM_* package description 2019-07-10 09:02:10 +02:00
mysql_add_executable.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
mysql_version.cmake cleanup: CPACK_RPM_* package description 2019-07-10 09:02:10 +02:00
numa.cmake MDEV-11195: Simplify enablement of NUMA in innodb/xtradb 2016-11-02 14:37:43 +11:00
package_name.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
pcre.cmake MDEV-13412 main.func_regexp_pcre fails in buildbot on ppc64le 2017-10-09 17:51:34 +02:00
plugin.cmake MDEV-20377: Introduce cmake -DWITH_MSAN:BOOL=ON 2019-08-19 20:56:26 +03:00
readline.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
sign.cmake.in Build improvements and cleanups. 2017-09-08 18:22:15 +00:00
ssl.cmake Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
stack_direction.c Update FSF Address 2019-05-11 21:29:06 +03:00
submodules.cmake typo cmake/submodules.cmake 2019-02-13 17:48:12 +11:00
systemd.cmake Merge 10.1 into 10.2 2019-07-09 13:22:22 +03:00
tags.cmake Update FSF Address 2019-05-11 21:29:06 +03:00
versioninfo.rc.in Update FSF Address 2019-05-11 21:29:06 +03:00
win_compatibility.manifest MDEV-12207 Include windows compatibility manifest into executable to make GetVersionEx work correctly 2017-03-08 11:20:03 +00:00
wsrep.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
zlib.cmake Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00