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 781AE5A026F for ; Thu, 16 Nov 2023 06:43:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1700113431; bh=1Z25JbJ4/xRgWjXLjw0bREWE7SU8D3cRxUa0OPqvxwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SL/roBb4lzkc6KN0sQNOFlorC8i8YE/2h0flKEztHuSvRPQDagFHrykm6xbcxRSsd xXnAtMLkBtWP6KBD6hIJyBTfscaAWkJir3aDbIi1DLDUxmxG1VO9mgOfWaBuN2Ruab fN9bGodshbRX5XX4OVTow48HKkhqivamUoyxBBes= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SW8936xL6z4x5J; Thu, 16 Nov 2023 16:43:51 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 2/2] valgrind: Don't disable optimizations for valgrind builds Date: Thu, 16 Nov 2023 16:43:50 +1100 Message-ID: <20231116054350.3255485-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231116054350.3255485-1-david@gibson.dropbear.id.au> References: <20231116054350.3255485-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: ERCJUXSCVDF6DNRPCZ6DUUP45U3TD53D X-Message-ID-Hash: ERCJUXSCVDF6DNRPCZ6DUUP45U3TD53D 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