From patchwork Wed Sep 25 17:11:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 830476 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:1374:b0:367:895a:4699 with SMTP id q20csp856186wrz; Wed, 25 Sep 2024 10:12:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV3ti8RSHb5Ww59Zb6ZpFR9dcGJRXYc8gJzrAJT2GfCqKgSmoEk9cDfsPsKF36PB1W7lmXy1g==@linaro.org X-Google-Smtp-Source: AGHT+IGMzTXQfBrJmgubZm0MmwbxOibszoKDNWqcifqtb86xscBOFFa/PDLEfkw/9ceZIktkqcJp X-Received: by 2002:a05:6358:9485:b0:1b8:2cf8:cf5 with SMTP id e5c5f4694b2df-1bea8564983mr284179455d.3.1727284360669; Wed, 25 Sep 2024 10:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727284360; cv=none; d=google.com; s=arc-20240605; b=BwEIDhCQDvaHpxilHsjOfMPt5HCRPDrXUhKUYg+9OjB+ww7Cbnz8p93+VqjnKfWMwn bOjNDnbWQPbrRXgQR2U3jAasA9Af/MusaAe9U/xm3Qf6ynkLMPo1Hy9ttWqR4SS6yMGd jH40Ux1X8xsE6PBlJ5k8SsxoVRLFOKGDqwB68VzxI/gm2W3A2c3K7PpJBjPXYg4e7B4T mEX0GCsztYsFjDEx+2sZ5CEL8BHKA6QZzo2Djif5pDOKrjYUKr6pLv9J+VZWwQL44o1v typHm5YjtHyP2gAi0zkiKb/6hRunfI7Zk6ZB9h0Ivwel/041Ckhp8qzNDDykjfDhKLKp NtQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=iZZo1oPZPqzjBeoixQ7wpptFRyTvJhgIff9wczeHXgQ=; fh=jOpm9kmPAspKh5iBNE/fo3cA2AnxrIpta9f9jvC2IBE=; b=fMpkzSPKhnEc7SutyWh50DWADTpRRvmAWW73dbTbarNIOcHdw72A5+kwxQpbveWSBH 5sG5Z1218VXjhKQ2s7ZmzMn5bloH9SqWOnXhLcv4d6vc+AXofEncCdqbU1N3ZyXQCR4s AXSqV0cANTkJaYuDsqGtLzpCSz0TSZirSYPuVWtiSDWINa7QWIFaESPQxzVD4aH/dpX6 SotqESE0LcL2mgzRfSodCgDFuYP/4SSg6YnO4gRrDu9HQ6muOAzrmJSMf4S+0b02YpkW E0U2SCueU/pvmuW2vWTmgSRtHR+lYym8cvz7euvaE0uOeoRf89PdkiwtwR5NCjqRKg00 pajw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F+wDMAys; 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 d75a77b69052e-45b5267f79bsi42239491cf.244.2024.09.25.10.12.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Sep 2024 10:12:40 -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=F+wDMAys; 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 1stVYg-0001EF-UZ; Wed, 25 Sep 2024 13:12:11 -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 1stVYS-0000L5-Sy for qemu-devel@nongnu.org; Wed, 25 Sep 2024 13:11:57 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1stVYR-0000e6-4I for qemu-devel@nongnu.org; Wed, 25 Sep 2024 13:11:56 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-42e82f7f36aso332005e9.0 for ; Wed, 25 Sep 2024 10:11:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727284311; x=1727889111; 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=iZZo1oPZPqzjBeoixQ7wpptFRyTvJhgIff9wczeHXgQ=; b=F+wDMAyseyCEbYjh1BMicl7R5jsvD7kwkuVevrslrVCeZFS7PtA6E+HpK+9nokbaFw TQBXEvJY1Z/gsEuQEbWzbHOQpyP7EDSgRukDcMYGhAG4cfKshV0D/IGVEQ9KNRPij8zK 2ZYtEWQv29/uAvL/qjLkjFhJwRXhWSKGW2Bt39SDsbkzG2xFOMbw/KistAjRnEJXF/5M eD7vO747clSLrcKujff+lcNpmbDv88FiOZNEG5eCzGdT+Il0fqjvrLmaqZW2Dq6oJSEf lYQdZCpQXMhRSXxQAAvVftuR5p+7Gz6LEfBJ6+5yFp5xIKeYQVz2I7+dGw7CKajQ8Moq M/xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727284311; x=1727889111; 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=iZZo1oPZPqzjBeoixQ7wpptFRyTvJhgIff9wczeHXgQ=; b=l7bv29nrH7hogwJ7aVkjxjDjDqJLshVFsMeRONJC0YNPRd0ghdETQ/xlosX78663+2 2ij2NNTNueM/B1q0Iy2tCoMq5A5LWI2YW+q08rH+2w5fBZV2vaAMHuQ8zTHR1BY0AoIE UaiO/LKHuDmKmU5OY7yj6qiwrfAn64x8Jcjo1oaBRqnCEh7Xt8BWuPPjl5qU9NO0NDtU HUxxaoa0sKJkkpwX2ISnzqTTDn77EDoobnm3xpUFXy+Q+R6GfybjyA1h8fDudlNkd/HV CjsDWMhHarKFy34Wu5wL5Q1rqapIynIWMOpz647UPCoUJL3ZDm/e4NzS5HHsgjfUowM8 I6wA== X-Gm-Message-State: AOJu0YwJv9mMjjISgeb5/P+VUwvymU8uTO17StwrUXxJrchdY29PzmzF TLR+WgdIFlIgEokw5TPj4aQRQljejH8m+DLTINaOWjXO0V+EGCmYavsrig8frUc= X-Received: by 2002:a05:600c:468b:b0:42c:c401:6d8b with SMTP id 5b1f17b1804b1-42e96103b5emr22700045e9.7.1727284311162; Wed, 25 Sep 2024 10:11:51 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42e96a36287sm24053595e9.29.2024.09.25.10.11.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Sep 2024 10:11:44 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 05F675FA4B; Wed, 25 Sep 2024 18:11:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Zhao Liu , "Edgar E. Iglesias" , Marcel Apfelbaum , Alexandre Iooss , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Mahmoud Mandour , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Richard Henderson , Paolo Bonzini , Eduardo Habkost , Pierrick Bouvier , Wainer dos Santos Moschetta , kvm@vger.kernel.org, Jiaxun Yang , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , qemu-arm@nongnu.org, Peter Maydell , devel@lists.libvirt.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Marcelo Tosatti , Laurent Vivier , Yanan Wang , Thomas Huth , Beraldo Leal Subject: [PATCH 07/10] docs/devel: update tsan build documentation Date: Wed, 25 Sep 2024 18:11:37 +0100 Message-Id: <20240925171140.1307033-8-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20240925171140.1307033-1-alex.bennee@linaro.org> References: <20240925171140.1307033-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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 From: Pierrick Bouvier 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 Reviewed-by: Thomas Huth Message-Id: <20240910174013.1433331-4-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée --- docs/devel/testing/main.rst | 26 ++++++++++++++++++++++---- 1 file 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.