From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 741455A026F for ; Thu, 16 Nov 2023 10:16:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1700126161; bh=1Z25JbJ4/xRgWjXLjw0bREWE7SU8D3cRxUa0OPqvxwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f+hd8Z/1FrrrtI0w0IxYDCNIsyeheszCOnXV+tqV6RGakG6z3BW6b8rZO1Rmtxqnb paUHX7gljtaXdyrPl0fodRsJfv3ZKEnv7mGuf0LgtebSLo/UPwqDoRMozpIAK1xnCa rFB+3QLKhJ0blpDyGIVlAtBDMp0QPbG4v5lJAlW4= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SWDss3Xb7z4x5m; Thu, 16 Nov 2023 20:16:01 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v3 2/2] valgrind: Don't disable optimizations for valgrind builds Date: Thu, 16 Nov 2023 20:15:59 +1100 Message-ID: <20231116091559.3258952-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231116091559.3258952-1-david@gibson.dropbear.id.au> References: <20231116091559.3258952-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: A47PZFY5WQ7RUUO7YGO72PBVRT3B6X45 X-Message-ID-Hash: A47PZFY5WQ7RUUO7YGO72PBVRT3B6X45 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: When we plan to use valgrind, we need to build passt a bit differently: * We need debug symbols so that valgrind can match problems it finds to meaningful locations * We need to allow additional syscalls in the seccomp filter, because valgrind's wrappers need them Currently we also disable optimization (-O0). This is unfortunate, because it will make valgrind tests even slower than they'd otherwise be. Worse, it's possible that the asm behaviour without optimization might be different enough that valgrind could miss a use of uninitialized variable or other fault it would detect. I suspect this was originally done because without it inlining could mean that suppressions we use don't reliably match the places we want them to. Alas, it turns out this is true even with -O0. We've now implemented a more robust workaround for this (explicit ((noinline)) attributes when compiled with -DVALGRIND). So, we can re-enable optimization for valgrind builds, making them closer to regular builds. Signed-off-by: David Gibson --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 57b2544..6c53695 100644 --- a/Makefile +++ b/Makefile @@ -128,7 +128,7 @@ qrap: $(QRAP_SRCS) passt.h valgrind: EXTRA_SYSCALLS += rt_sigprocmask rt_sigtimedwait rt_sigaction \ getpid gettid kill clock_gettime mmap \ munmap open unlink gettimeofday futex -valgrind: FLAGS:=-g -O0 $(filter-out -O%,$(FLAGS)) -DVALGRIND +valgrind: FLAGS += -g -DVALGRIND valgrind: all .PHONY: clean -- 2.41.0