From patchwork Thu Nov 23 18:13:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Monakov X-Patchwork-Id: 1867896 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SbmTZ08fKz1yRw for ; Fri, 24 Nov 2023 05:14:10 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A7D7D384DEE9 for ; Thu, 23 Nov 2023 18:14:06 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id B859A3858C31 for ; Thu, 23 Nov 2023 18:13:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B859A3858C31 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B859A3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=83.149.199.84 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700763234; cv=none; b=V0FPqmDnxf5agcgLOLRT5cjZAhz9KtFn7X/dHI0QucwMco+6goubzcTr95RhBmOWkLqNFZMgpyI4DVX7hih+r7KXSFXrJoTJk2KjqZOen2AVM8AE887nr/MD5AkdY2QhjarnAZlIAUc46VnzaL15UPCqN0tlocPIcekXKgHD8W0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700763234; c=relaxed/simple; bh=v1Qs6ortFWet0GIgAOgB4B7C5i5o9PAsHd+3nB3dBXg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=re/5o2dR/UrdgPGrHCanWK+HesEey6zWFiAg6HeX3ECwXvCPj3vQktnqjclvSGOTL3nGOM7qp5VZEBYEicPEl7a+5j0LXqHVMfg18yGF4Jc12z9Pk1iN6tdcpP76Vb6YISF/nfybVLRIrfi72lfLZHYtYO1pYLyX/uAZ512CDsY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.intra.ispras.ru (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTP id 5708840737BF; Thu, 23 Nov 2023 18:13:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 5708840737BF From: Alexander Monakov To: gcc-patches@gcc.gnu.org Cc: Alexander Monakov Subject: [PATCH 1/2] libcpp: configure: drop unused Valgrind detection Date: Thu, 23 Nov 2023 21:13:42 +0300 Message-Id: <20231123181343.27624-2-amonakov@ispras.ru> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231123181343.27624-1-amonakov@ispras.ru> References: <20231123181343.27624-1-amonakov@ispras.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When top-level configure has either --enable-checking=valgrind or --enable-valgrind-annotations, we want to activate a couple of workarounds in libcpp. They do not use anything from the Valgrind API, so just delete all detection. libcpp/ChangeLog: * config.in: Regenerate. * configure: Regenerate. * configure.ac (ENABLE_VALGRIND_CHECKING): Delete. (ENABLE_VALGRIND_ANNOTATIONS): Rename to ENABLE_VALGRIND_WORKAROUNDS. Delete Valgrind header checks. * lex.cc (new_buff): Adjust for renaming. (_cpp_free_buff): Ditto. --- libcpp/config.in | 15 ++-------- libcpp/configure | 70 +-------------------------------------------- libcpp/configure.ac | 51 ++------------------------------- libcpp/lex.cc | 4 +-- 4 files changed, 9 insertions(+), 131 deletions(-) diff --git a/libcpp/config.in b/libcpp/config.in index df4fd44c9e..253ef03a3d 100644 --- a/libcpp/config.in +++ b/libcpp/config.in @@ -24,12 +24,9 @@ language is requested. */ #undef ENABLE_NLS -/* Define to get calls to the valgrind runtime enabled. */ -#undef ENABLE_VALGRIND_ANNOTATIONS - -/* Define if you want to workaround valgrind (a memory checker) warnings about - possible memory leaks because of libcpp use of interior pointers. */ -#undef ENABLE_VALGRIND_CHECKING +/* Define if you want to workaround Valgrind warnings about possible memory + leaks because of libcpp use of interior pointers. */ +#undef ENABLE_VALGRIND_WORKAROUNDS /* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA @@ -201,9 +198,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H -/* Define if valgrind's memcheck.h header is installed. */ -#undef HAVE_MEMCHECK_H - /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -252,9 +246,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* Define if valgrind's valgrind/memcheck.h header is installed. */ -#undef HAVE_VALGRIND_MEMCHECK_H - /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST diff --git a/libcpp/configure b/libcpp/configure index 452e4c1f6c..8a38c0546e 100755 --- a/libcpp/configure +++ b/libcpp/configure @@ -9116,12 +9116,6 @@ $as_echo "#define ENABLE_ASSERT_CHECKING 1" >>confdefs.h fi -if test x$ac_valgrind_checking != x ; then - -$as_echo "#define ENABLE_VALGRIND_CHECKING 1" >>confdefs.h - -fi - # Check whether --enable-canonical-system-headers was given. if test "${enable_canonical_system_headers+set}" = set; then : enableval=$enable_canonical_system_headers; @@ -9405,62 +9399,6 @@ case x$enable_languages in esac -ac_fn_c_check_header_mongrel "$LINENO" "valgrind.h" "ac_cv_header_valgrind_h" "$ac_includes_default" -if test "x$ac_cv_header_valgrind_h" = xyes; then : - have_valgrind_h=yes -else - have_valgrind_h=no -fi - - - -# It is certainly possible that there's valgrind but no valgrind.h. -# GCC relies on making annotations so we must have both. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for VALGRIND_DISCARD in " >&5 -$as_echo_n "checking for VALGRIND_DISCARD in ... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#ifndef VALGRIND_DISCARD -#error VALGRIND_DISCARD not defined -#endif -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - gcc_cv_header_valgrind_memcheck_h=yes -else - gcc_cv_header_valgrind_memcheck_h=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_valgrind_memcheck_h" >&5 -$as_echo "$gcc_cv_header_valgrind_memcheck_h" >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for VALGRIND_DISCARD in " >&5 -$as_echo_n "checking for VALGRIND_DISCARD in ... " >&6; } -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -#ifndef VALGRIND_DISCARD -#error VALGRIND_DISCARD not defined -#endif -_ACEOF -if ac_fn_c_try_cpp "$LINENO"; then : - gcc_cv_header_memcheck_h=yes -else - gcc_cv_header_memcheck_h=no -fi -rm -f conftest.err conftest.i conftest.$ac_ext -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_header_memcheck_h" >&5 -$as_echo "$gcc_cv_header_memcheck_h" >&6; } -if test $gcc_cv_header_valgrind_memcheck_h = yes; then - -$as_echo "#define HAVE_VALGRIND_MEMCHECK_H 1" >>confdefs.h - -fi -if test $gcc_cv_header_memcheck_h = yes; then - -$as_echo "#define HAVE_MEMCHECK_H 1" >>confdefs.h - -fi - # Check whether --enable-valgrind-annotations was given. if test "${enable_valgrind_annotations+set}" = set; then : enableval=$enable_valgrind_annotations; @@ -9470,14 +9408,8 @@ fi if test x$enable_valgrind_annotations != xno \ || test x$ac_valgrind_checking != x; then - if (test $have_valgrind_h = no \ - && test $gcc_cv_header_memcheck_h = no \ - && test $gcc_cv_header_valgrind_memcheck_h = no); then - as_fn_error $? "*** valgrind annotations requested, but" "$LINENO" 5 - as_fn_error $? "*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h" "$LINENO" 5 - fi -$as_echo "#define ENABLE_VALGRIND_ANNOTATIONS 1" >>confdefs.h +$as_echo "#define ENABLE_VALGRIND_WORKAROUNDS 1" >>confdefs.h fi diff --git a/libcpp/configure.ac b/libcpp/configure.ac index b29b4d6acf..b883fec776 100644 --- a/libcpp/configure.ac +++ b/libcpp/configure.ac @@ -185,12 +185,6 @@ if test x$ac_assert_checking != x ; then [Define if you want assertions enabled. This is a cheap check.]) fi -if test x$ac_valgrind_checking != x ; then - AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1, -[Define if you want to workaround valgrind (a memory checker) warnings about - possible memory leaks because of libcpp use of interior pointers.]) -fi - AC_ARG_ENABLE(canonical-system-headers, [ --enable-canonical-system-headers enable or disable system headers canonicalization], @@ -241,54 +235,15 @@ case x$enable_languages in esac AC_SUBST(CET_HOST_FLAGS) -dnl # This check AC_REQUIREs various stuff, so it *must not* be inside -dnl # an if statement. This was the source of very frustrating bugs -dnl # in converting to autoconf 2.5x! -AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no) - -# It is certainly possible that there's valgrind but no valgrind.h. -# GCC relies on making annotations so we must have both. -AC_MSG_CHECKING(for VALGRIND_DISCARD in ) -AC_PREPROC_IFELSE([AC_LANG_SOURCE( - [[#include -#ifndef VALGRIND_DISCARD -#error VALGRIND_DISCARD not defined -#endif]])], - [gcc_cv_header_valgrind_memcheck_h=yes], - [gcc_cv_header_valgrind_memcheck_h=no]) -AC_MSG_RESULT($gcc_cv_header_valgrind_memcheck_h) -AC_MSG_CHECKING(for VALGRIND_DISCARD in ) -AC_PREPROC_IFELSE([AC_LANG_SOURCE( - [[#include -#ifndef VALGRIND_DISCARD -#error VALGRIND_DISCARD not defined -#endif]])], - [gcc_cv_header_memcheck_h=yes], - [gcc_cv_header_memcheck_h=no]) -AC_MSG_RESULT($gcc_cv_header_memcheck_h) -if test $gcc_cv_header_valgrind_memcheck_h = yes; then - AC_DEFINE(HAVE_VALGRIND_MEMCHECK_H, 1, - [Define if valgrind's valgrind/memcheck.h header is installed.]) -fi -if test $gcc_cv_header_memcheck_h = yes; then - AC_DEFINE(HAVE_MEMCHECK_H, 1, - [Define if valgrind's memcheck.h header is installed.]) -fi - AC_ARG_ENABLE(valgrind-annotations, [AS_HELP_STRING([--enable-valgrind-annotations], [enable valgrind runtime interaction])], [], [enable_valgrind_annotations=no]) if test x$enable_valgrind_annotations != xno \ || test x$ac_valgrind_checking != x; then - if (test $have_valgrind_h = no \ - && test $gcc_cv_header_memcheck_h = no \ - && test $gcc_cv_header_valgrind_memcheck_h = no); then - AC_MSG_ERROR([*** valgrind annotations requested, but]) - AC_MSG_ERROR([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h]) - fi - AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1, -[Define to get calls to the valgrind runtime enabled.]) + AC_DEFINE(ENABLE_VALGRIND_WORKAROUNDS, 1, +[Define if you want to workaround Valgrind warnings about + possible memory leaks because of libcpp use of interior pointers.]) fi # Output. diff --git a/libcpp/lex.cc b/libcpp/lex.cc index 0b1b93609e..a5d2f31e76 100644 --- a/libcpp/lex.cc +++ b/libcpp/lex.cc @@ -4762,7 +4762,7 @@ new_buff (size_t len) len = MIN_BUFF_SIZE; len = CPP_ALIGN (len); -#ifdef ENABLE_VALGRIND_ANNOTATIONS +#ifdef ENABLE_VALGRIND_WORKAROUNDS /* Valgrind warns about uses of interior pointers, so put _cpp_buff struct first. */ size_t slen = CPP_ALIGN2 (sizeof (_cpp_buff), 2 * DEFAULT_ALIGNMENT); @@ -4859,7 +4859,7 @@ _cpp_free_buff (_cpp_buff *buff) for (; buff; buff = next) { next = buff->next; -#ifdef ENABLE_VALGRIND_ANNOTATIONS +#ifdef ENABLE_VALGRIND_WORKAROUNDS free (buff); #else free (buff->base);