From patchwork Wed Aug 14 17:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 819144 Delivered-To: patch@linaro.org Received: by 2002:adf:cd01:0:b0:367:895a:4699 with SMTP id w1csp802738wrm; Wed, 14 Aug 2024 10:13:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVMux26yPrip2nhdlj4uqN/1gzocYLbJzYrIYwVGYMtgy3ivAUpiiA+NfTG2+4xERVfVdl+xae4/k5ezLgviNSo X-Google-Smtp-Source: AGHT+IGboAYUbLF9hkMfw6z2bouM390vk63sM31ZUGkyWcHQQQQ1X7/t+Nlq27UxRqFX2unYSPhg X-Received: by 2002:a05:620a:424f:b0:7a1:dfd0:80c9 with SMTP id af79cd13be357-7a4ee330d05mr442288385a.27.1723655613640; Wed, 14 Aug 2024 10:13:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723655613; cv=none; d=google.com; s=arc-20160816; b=kv/wQJqnLxFNfN/hbx/So/8b0snuhbnn9Da2EhlChzMHORXWw+e5QrGS+YMsnKgAPV pxXL3nSUnVXP8CtST9KQqmsD/B0hNr4S9QnyMiXx4Zj0faNBtoAjed2oN/DFdIh1GuMT nexBnmvrFoN6FvIfQvioFCFBQX/kHcEXqWalItj0wdTlhJQcPMC21Qo2IYS87koHEkGM kXGfpEYmHikT83SdezRd2CZ8+7FUCR+IiLZWOBQVczEIgpO6+YVgPLkBcQurzMigc9Pl EV/bflUAWnxIiyBpjIw5EJnvLVqQ0jhTLVmx8O9ORr54Uo31rrivKdZW47DNglKaursV zDiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cUn79WU14zqlH0c8ZH40FfQUSvZAWtp5MDwWi4t6xwQ=; fh=2zasdEIMl2g9By/aYULsdPxvg2j0c442hBqLZY0SAzw=; b=jXKfxnfNEQMa/3Wm4EWyeRAK6qcs4F2Ffj+omZseYpK7uacQGPIwbl80E7sdXeJXMK nGlJ66+iQhE5bweXdj2uacp4DPCdC1Lnrly9NSpNvZETc6P+i90pa49Mw7nbbyAkkpp+ OKdtkioAqJvzNXefGhwLjeCBsOp7/fCMifk0O8cY5Om0j34irsbX0NxfP6Q+ja4yDVtD ECG10Lk9/5wvbZHxIGprcUMLbep6aDquxgubce/BMU6dRHCxUVIQUtq5tnDH7d9fRtQK 0dr6j2O0pfRpo7TUINohj9YtxCGqAbhU2KcQySdnBCbhN1qwi0XjdmvdUpc+46naJtYq SQEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JmphD9tM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a4c7d66195si1100139085a.91.2024.08.14.10.13.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Aug 2024 10:13:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JmphD9tM; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1seHXm-0000Pe-GO; Wed, 14 Aug 2024 13:12:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1seHXg-0000BP-Qs for qemu-devel@nongnu.org; Wed, 14 Aug 2024 13:12:14 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1seHXe-0006DL-CI for qemu-devel@nongnu.org; Wed, 14 Aug 2024 13:12:12 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-201d6ac1426so646545ad.1 for ; Wed, 14 Aug 2024 10:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723655529; x=1724260329; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cUn79WU14zqlH0c8ZH40FfQUSvZAWtp5MDwWi4t6xwQ=; b=JmphD9tMByaiGwa4V/M0iw0DqnZtFtQr1qGtn8E/v7q/7BFiGheQKVwirWqz82DW6H sFbl2ivpjGLLiiseWjDklVHJ9ofD+DpXtyK0TGNZXfJATtdugo7i+sqTajoNlJJ6QBGK HwBbZNoHdUzLc6DBdFWeq+FV6p6FiU4HDM08Zq4GL9jhvMRWhKRpgJqblazeb8oJi0w1 k1jo6r9PqakI9qcYCfFkwiCcL/fr/ZemnaPZQONAO26kjYMJxSI1VYa85tcYc6/tqrKc JBLHoMu9e5tBWkhWLAgKMZFFBpRLhINBEVOmlOc9MxJrHfZ1yxRTH3iOvNmDwphGBn8M iHFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723655529; x=1724260329; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cUn79WU14zqlH0c8ZH40FfQUSvZAWtp5MDwWi4t6xwQ=; b=Q6nQbZ5uGKJOM3JbRoWXCMRl1Tny+TH9rmxBHKElVNZB8aK1BBcuLfQsAOiXo+L6ZV bXB3Ggb4dEDf54EGiMQgVac05DNgW+nKHFbwtZ/IScP76qEmOSwjLn0dXF1tTNrdlNYd wzdeacxx8Eangj26anAn0YuEoXAfJYZL58ttDDjkzKltP4KGusRmLT7EMwNfWwK/FibF BTuW/YMdyM4rIvGY9UwoXjIFB/JVf/mWewlnZ4gwVSZJPRhzV3DDZW9Nnxt3heQ1KyDl uQTtko4K3fCNK/eB1kvE0mUSgGGolTfPwgVOFnRA1KYw6SQACKm6qXXpQsRH8v6DxH7r VtpQ== X-Gm-Message-State: AOJu0YzaevXKnpmA8xWL+20ZPLzoEuoPE4KW2rS/ugXvfSjtmRpoVBV+ U4kliRMh6FiYKFh+Ut3VC2fm0gZHy28qnJH482+E6LfM73Del0B0a5wwhiya4UGc7gbyB+randj YT0s= X-Received: by 2002:a17:903:11c8:b0:1ff:49c:1562 with SMTP id d9443c01a7336-201d64d8afcmr37992915ad.56.1723655528927; Wed, 14 Aug 2024 10:12:08 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::b861]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-201cd1c8783sm31813895ad.245.2024.08.14.10.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 10:12:08 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Marcelo Tosatti , kvm@vger.kernel.org, Wainer dos Santos Moschetta , Thomas Huth , David Hildenbrand , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , qemu-s390x@nongnu.org, Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , Beraldo Leal , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Richard Henderson , =?utf-8?q?Daniel_P=2E_Ber?= =?utf-8?q?rang=C3=A9?= , Pierrick Bouvier Subject: [PATCH 4/4] docs/devel: update tsan build documentation Date: Wed, 14 Aug 2024 10:11:52 -0700 Message-Id: <20240814171152.575634-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240814171152.575634-1-pierrick.bouvier@linaro.org> References: <20240814171152.575634-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::629; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Mention it's now possible to build with gcc, instead of clang, and explain how to build a sanitized glib version. --- docs/devel/testing.rst | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/docs/devel/testing.rst b/docs/devel/testing.rst index af73d3d64fb..f10cfc3f786 100644 --- a/docs/devel/testing.rst +++ b/docs/devel/testing.rst @@ -634,20 +634,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.