aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPierrick Bouvier <pierrick.bouvier@linaro.org>2024-10-23 12:33:53 +0100
committerAlex Bennée <alex.bennee@linaro.org>2024-10-24 09:56:12 +0100
commitdfbc72a77cd9441e8c29aebb2ea11547972806f0 (patch)
tree8447748d88665d1c1b199fb8aa52fc5329ee7cbe /docs
parentcf6fbba724f19355d31b7d8dd1a711538dd91645 (diff)
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 <pierrick.bouvier@linaro.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20240910174013.1433331-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20241023113406.1284676-6-alex.bennee@linaro.org>
Diffstat (limited to 'docs')
-rw-r--r--docs/devel/testing/main.rst26
1 files changed, 22 insertions, 4 deletions
diff --git a/docs/devel/testing/main.rst b/docs/devel/testing/main.rst
index 09725e8ea9..91f4dc61fb 100644
--- a/docs/devel/testing/main.rst
+++ b/docs/devel/testing/main.rst
@@ -628,20 +628,38 @@ Building and Testing with TSan
It is possible to build and test with TSan, with a few additional steps.
These steps are normally done automatically in the docker.
-There is a one time patch needed in clang-9 or clang-10 at this time:
+TSan is supported for clang and gcc.
+One particularity of sanitizers is that all the code, including shared objects
+dependencies, should be built with it.
+In the case of TSan, any synchronization primitive from glib (GMutex for
+instance) will not be recognized, and will lead to false positives.
+
+To build a tsan version of glib:
.. code::
- sed -i 's/^const/static const/g' \
- /usr/lib/llvm-10/lib/clang/10.0.0/include/sanitizer/tsan_interface.h
+ $ git clone --depth=1 --branch=2.81.0 https://github.com/GNOME/glib.git
+ $ cd glib
+ $ CFLAGS="-O2 -g -fsanitize=thread" meson build
+ $ ninja -C build
To configure the build for TSan:
.. code::
- ../configure --enable-tsan --cc=clang-10 --cxx=clang++-10 \
+ ../configure --enable-tsan \
--disable-werror --extra-cflags="-O0"
+When executing qemu, don't forget to point to tsan glib:
+
+.. code::
+
+ $ glib_dir=/path/to/glib
+ $ export LD_LIBRARY_PATH=$glib_dir/build/gio:$glib_dir/build/glib:$glib_dir/build/gmodule:$glib_dir/build/gobject:$glib_dir/build/gthread
+ # check correct version is used
+ $ ldd build/qemu-x86_64 | grep glib
+ $ qemu-system-x86_64 ...
+
The runtime behavior of TSAN is controlled by the TSAN_OPTIONS environment
variable.