Skip to content

Commit 9216445

Browse files
committed
docs/devel: update tsan build documentation
Mention it's now possible to build with gcc, instead of clang, and explain how to build a sanitized glib version. Signed-off-by: Pierrick Bouvier <[email protected]>
1 parent f1266e0 commit 9216445

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

docs/devel/testing/main.rst

+22-4
Original file line numberDiff line numberDiff line change
@@ -628,20 +628,38 @@ Building and Testing with TSan
628628
It is possible to build and test with TSan, with a few additional steps.
629629
These steps are normally done automatically in the docker.
630630

631-
There is a one time patch needed in clang-9 or clang-10 at this time:
631+
TSan is supported for clang and gcc.
632+
One particularity of sanitizers is that all the code, including shared objects
633+
dependencies, should be built with it.
634+
In the case of TSan, any synchronization primitive from glib (GMutex for
635+
instance) will not be recognized, and will lead to false positives.
636+
637+
To build a tsan version of glib:
632638

633639
.. code::
634640
635-
sed -i 's/^const/static const/g' \
636-
/usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h
641+
$ git clone --depth=1 --branch=2.81.0 https://github.com/GNOME/glib.git
642+
$ cd glib
643+
$ CFLAGS="-O2 -g -fsanitize=thread" meson build
644+
$ ninja -C build
637645
638646
To configure the build for TSan:
639647

640648
.. code::
641649
642-
../configure --enable-tsan --cc=clang-10 --cxx=clang++-10 \
650+
../configure --enable-tsan \
643651
--disable-werror --extra-cflags="-O0"
644652
653+
When executing qemu, don't forget to point to tsan glib:
654+
655+
.. code::
656+
657+
$ glib_dir=/path/to/glib
658+
$ export LD_LIBRARY_PATH=$glib_dir/build/gio:$glib_dir/build/glib:$glib_dir/build/gmodule:$glib_dir/build/gobject:$glib_dir/build/gthread
659+
# check correct version is used
660+
$ ldd build/qemu-x86_64 | grep glib
661+
$ qemu-system-x86_64 ...
662+
645663
The runtime behavior of TSAN is controlled by the TSAN_OPTIONS environment
646664
variable.
647665

0 commit comments

Comments
 (0)