* [PATCH 0/2] Clean up Valgrind configury
@ 2023-11-23 18:13 Alexander Monakov
2023-11-23 18:13 ` [PATCH 1/2] libcpp: configure: drop unused Valgrind detection Alexander Monakov
2023-11-23 18:13 ` [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility Alexander Monakov
0 siblings, 2 replies; 5+ messages in thread
From: Alexander Monakov @ 2023-11-23 18:13 UTC (permalink / raw)
To: gcc-patches; +Cc: Alexander Monakov
We have an RFC patch [1] that adds a libgcc wrapper for a Valgrind client
request. GCC has autoconf detection for Valgrind in the compiler proper
as well as libcpp (where it is actually unnecessary).
It's grown rusty, let's clean it up.
[1] https://inbox.sourceware.org/gcc-patches/20231024141124.210708-1-exactlywb@ispras.ru/
Alexander Monakov (2):
libcpp: configure: drop unused Valgrind detection
gcc: configure: drop Valgrind 3.1 compatibility
gcc/config.in | 12 -------
gcc/configure | 80 +++++++--------------------------------------
gcc/configure.ac | 49 +++------------------------
gcc/system.h | 23 ++-----------
libcpp/config.in | 15 ++-------
libcpp/configure | 70 +--------------------------------------
libcpp/configure.ac | 51 ++---------------------------
libcpp/lex.cc | 4 +--
8 files changed, 29 insertions(+), 275 deletions(-)
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] libcpp: configure: drop unused Valgrind detection
2023-11-23 18:13 [PATCH 0/2] Clean up Valgrind configury Alexander Monakov
@ 2023-11-23 18:13 ` Alexander Monakov
2023-11-24 8:10 ` Richard Biener
2023-11-23 18:13 ` [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility Alexander Monakov
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Monakov @ 2023-11-23 18:13 UTC (permalink / raw)
To: gcc-patches; +Cc: Alexander Monakov
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 <locale.h> 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 <memory.h> header file. */
#undef HAVE_MEMORY_H
@@ -252,9 +246,6 @@
/* Define to 1 if you have the <unistd.h> 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 <valgrind/memcheck.h>" >&5
-$as_echo_n "checking for VALGRIND_DISCARD in <valgrind/memcheck.h>... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <valgrind/memcheck.h>
-#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 <memcheck.h>" >&5
-$as_echo_n "checking for VALGRIND_DISCARD in <memcheck.h>... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <memcheck.h>
-#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 <valgrind/memcheck.h>)
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(
- [[#include <valgrind/memcheck.h>
-#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 <memcheck.h>)
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(
- [[#include <memcheck.h>
-#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);
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility
2023-11-23 18:13 [PATCH 0/2] Clean up Valgrind configury Alexander Monakov
2023-11-23 18:13 ` [PATCH 1/2] libcpp: configure: drop unused Valgrind detection Alexander Monakov
@ 2023-11-23 18:13 ` Alexander Monakov
2023-11-24 8:10 ` Richard Biener
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Monakov @ 2023-11-23 18:13 UTC (permalink / raw)
To: gcc-patches; +Cc: Alexander Monakov
Our system.h and configure.ac try to accommodate valgrind-3.1, but it is
more than 15 years old at this point. As Valgrind-based checking is a
developer-oriented feature, drop the compatibility stuff and streamline
the detection.
gcc/ChangeLog:
* config.in: Regenerate.
* configure: Regenerate.
* configure.ac: Delete manual checks for old Valgrind headers.
* system.h (VALGRIND_MAKE_MEM_NOACCESS): Delete.
(VALGRIND_MAKE_MEM_DEFINED): Delete.
(VALGRIND_MAKE_MEM_UNDEFINED): Delete.
(VALGRIND_MALLOCLIKE_BLOCK): Delete.
(VALGRIND_FREELIKE_BLOCK): Delete.
---
gcc/config.in | 12 --------
gcc/configure | 80 ++++++++----------------------------------------
gcc/configure.ac | 49 +++--------------------------
gcc/system.h | 23 ++------------
4 files changed, 20 insertions(+), 144 deletions(-)
diff --git a/gcc/config.in b/gcc/config.in
index e100c20dcd..3dfc65b844 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1868,12 +1868,6 @@
#endif
-/* Define if valgrind's memcheck.h header is installed. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_MEMCHECK_H
-#endif
-
-
/* Define to 1 if you have the <memory.h> header file. */
#ifndef USED_FOR_TARGET
#undef HAVE_MEMORY_H
@@ -2136,12 +2130,6 @@
#endif
-/* Define if valgrind's valgrind/memcheck.h header is installed. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_VALGRIND_MEMCHECK_H
-#endif
-
-
/* Define to 1 if you have the `vfork' function. */
#ifndef USED_FOR_TARGET
#undef HAVE_VFORK
diff --git a/gcc/configure b/gcc/configure
index cc0c3aad67..5be4592ba0 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -7679,63 +7679,6 @@ $as_echo "#define ENABLE_FOLD_CHECKING 1" >>confdefs.h
fi
valgrind_path_defines=
valgrind_command=
-
-ac_fn_cxx_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 <valgrind/memcheck.h>" >&5
-$as_echo_n "checking for VALGRIND_DISCARD in <valgrind/memcheck.h>... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <valgrind/memcheck.h>
-#ifndef VALGRIND_DISCARD
-#error VALGRIND_DISCARD not defined
-#endif
-_ACEOF
-if ac_fn_cxx_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 <memcheck.h>" >&5
-$as_echo_n "checking for VALGRIND_DISCARD in <memcheck.h>... " >&6; }
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-#include <memcheck.h>
-#ifndef VALGRIND_DISCARD
-#error VALGRIND_DISCARD not defined
-#endif
-_ACEOF
-if ac_fn_cxx_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
-
if test x$ac_valgrind_checking != x ; then
# Prepare PATH_SEPARATOR.
@@ -7804,11 +7747,8 @@ else
$as_echo "no" >&6; }
fi
- if test "x$valgrind_path" = "x" \
- || (test $have_valgrind_h = no \
- && test $gcc_cv_header_memcheck_h = no \
- && test $gcc_cv_header_valgrind_memcheck_h = no); then
- as_fn_error $? "*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h" "$LINENO" 5
+ if test "x$valgrind_path" = "x"; then
+ as_fn_error $? "*** Cannot find valgrind" "$LINENO" 5
fi
valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
valgrind_command="$valgrind_path -q"
@@ -7864,12 +7804,16 @@ else
enable_valgrind_annotations=no
fi
+ac_fn_cxx_check_header_mongrel "$LINENO" "valgrind/memcheck.h" "ac_cv_header_valgrind_memcheck_h" "$ac_includes_default"
+if test "x$ac_cv_header_valgrind_memcheck_h" = xyes; then :
+
+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 $? "*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h" "$LINENO" 5
+ if test $ac_cv_header_valgrind_memcheck_h = no; then
+ as_fn_error $? "*** Cannot find valgrind/memcheck.h" "$LINENO" 5
fi
$as_echo "#define ENABLE_VALGRIND_ANNOTATIONS 1" >>confdefs.h
@@ -21602,7 +21546,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21605 "configure"
+#line 21549 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -21708,7 +21652,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 21711 "configure"
+#line 21655 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index d9a35069e3..0cf5fda318 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -778,49 +778,11 @@ if test x$ac_fold_checking != x ; then
fi
valgrind_path_defines=
valgrind_command=
-
-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 <valgrind/memcheck.h>)
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(
- [[#include <valgrind/memcheck.h>
-#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 <memcheck.h>)
-AC_PREPROC_IFELSE([AC_LANG_SOURCE(
- [[#include <memcheck.h>
-#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
-
if test x$ac_valgrind_checking != x ; then
AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
[$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
- if test "x$valgrind_path" = "x" \
- || (test $have_valgrind_h = no \
- && test $gcc_cv_header_memcheck_h = no \
- && test $gcc_cv_header_valgrind_memcheck_h = no); then
- AC_MSG_ERROR([*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h])
+ if test "x$valgrind_path" = "x"; then
+ AC_MSG_ERROR([*** Cannot find valgrind])
fi
valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
valgrind_command="$valgrind_path -q"
@@ -869,12 +831,11 @@ AC_ARG_ENABLE(valgrind-annotations,
[AS_HELP_STRING([--enable-valgrind-annotations],
[enable valgrind runtime interaction])], [],
[enable_valgrind_annotations=no])
+AC_CHECK_HEADER(valgrind/memcheck.h)
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([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
+ if test $ac_cv_header_valgrind_memcheck_h = no; then
+ AC_MSG_ERROR([*** Cannot find valgrind/memcheck.h])
fi
AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
[Define to get calls to the valgrind runtime enabled.])
diff --git a/gcc/system.h b/gcc/system.h
index e924152ad4..16db87bd5a 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -1217,28 +1217,11 @@ helper_const_non_const_cast (const char *p)
#endif
#ifdef ENABLE_VALGRIND_ANNOTATIONS
-# ifdef HAVE_VALGRIND_MEMCHECK_H
-# include <valgrind/memcheck.h>
-# elif defined HAVE_MEMCHECK_H
-# include <memcheck.h>
-# else
-# include <valgrind.h>
-# endif
-/* Compatibility macros to let valgrind 3.1 work. */
-# ifndef VALGRIND_MAKE_MEM_NOACCESS
-# define VALGRIND_MAKE_MEM_NOACCESS VALGRIND_MAKE_NOACCESS
-# endif
-# ifndef VALGRIND_MAKE_MEM_DEFINED
-# define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_READABLE
-# endif
-# ifndef VALGRIND_MAKE_MEM_UNDEFINED
-# define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_WRITABLE
-# endif
+#include <valgrind/memcheck.h>
#else
-/* Avoid #ifdef:s when we can help it. */
+/* VALGRIND_DISCARD unregisters the given block handle,
+ but our code misuses it for discarding annotations. */
#define VALGRIND_DISCARD(x)
-#define VALGRIND_MALLOCLIKE_BLOCK(w,x,y,z)
-#define VALGRIND_FREELIKE_BLOCK(x,y)
#endif
/* Macros to temporarily ignore some warnings. */
--
2.39.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] libcpp: configure: drop unused Valgrind detection
2023-11-23 18:13 ` [PATCH 1/2] libcpp: configure: drop unused Valgrind detection Alexander Monakov
@ 2023-11-24 8:10 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2023-11-24 8:10 UTC (permalink / raw)
To: Alexander Monakov; +Cc: gcc-patches
On Thu, Nov 23, 2023 at 7:14 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>
> 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.
OK
> 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 <locale.h> 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 <memory.h> header file. */
> #undef HAVE_MEMORY_H
>
> @@ -252,9 +246,6 @@
> /* Define to 1 if you have the <unistd.h> 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 <valgrind/memcheck.h>" >&5
> -$as_echo_n "checking for VALGRIND_DISCARD in <valgrind/memcheck.h>... " >&6; }
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <valgrind/memcheck.h>
> -#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 <memcheck.h>" >&5
> -$as_echo_n "checking for VALGRIND_DISCARD in <memcheck.h>... " >&6; }
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <memcheck.h>
> -#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 <valgrind/memcheck.h>)
> -AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> - [[#include <valgrind/memcheck.h>
> -#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 <memcheck.h>)
> -AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> - [[#include <memcheck.h>
> -#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);
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility
2023-11-23 18:13 ` [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility Alexander Monakov
@ 2023-11-24 8:10 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2023-11-24 8:10 UTC (permalink / raw)
To: Alexander Monakov; +Cc: gcc-patches
On Thu, Nov 23, 2023 at 7:14 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>
> Our system.h and configure.ac try to accommodate valgrind-3.1, but it is
> more than 15 years old at this point. As Valgrind-based checking is a
> developer-oriented feature, drop the compatibility stuff and streamline
> the detection.
OK.
> gcc/ChangeLog:
>
> * config.in: Regenerate.
> * configure: Regenerate.
> * configure.ac: Delete manual checks for old Valgrind headers.
> * system.h (VALGRIND_MAKE_MEM_NOACCESS): Delete.
> (VALGRIND_MAKE_MEM_DEFINED): Delete.
> (VALGRIND_MAKE_MEM_UNDEFINED): Delete.
> (VALGRIND_MALLOCLIKE_BLOCK): Delete.
> (VALGRIND_FREELIKE_BLOCK): Delete.
> ---
> gcc/config.in | 12 --------
> gcc/configure | 80 ++++++++----------------------------------------
> gcc/configure.ac | 49 +++--------------------------
> gcc/system.h | 23 ++------------
> 4 files changed, 20 insertions(+), 144 deletions(-)
>
> diff --git a/gcc/config.in b/gcc/config.in
> index e100c20dcd..3dfc65b844 100644
> --- a/gcc/config.in
> +++ b/gcc/config.in
> @@ -1868,12 +1868,6 @@
> #endif
>
>
> -/* Define if valgrind's memcheck.h header is installed. */
> -#ifndef USED_FOR_TARGET
> -#undef HAVE_MEMCHECK_H
> -#endif
> -
> -
> /* Define to 1 if you have the <memory.h> header file. */
> #ifndef USED_FOR_TARGET
> #undef HAVE_MEMORY_H
> @@ -2136,12 +2130,6 @@
> #endif
>
>
> -/* Define if valgrind's valgrind/memcheck.h header is installed. */
> -#ifndef USED_FOR_TARGET
> -#undef HAVE_VALGRIND_MEMCHECK_H
> -#endif
> -
> -
> /* Define to 1 if you have the `vfork' function. */
> #ifndef USED_FOR_TARGET
> #undef HAVE_VFORK
> diff --git a/gcc/configure b/gcc/configure
> index cc0c3aad67..5be4592ba0 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -7679,63 +7679,6 @@ $as_echo "#define ENABLE_FOLD_CHECKING 1" >>confdefs.h
> fi
> valgrind_path_defines=
> valgrind_command=
> -
> -ac_fn_cxx_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 <valgrind/memcheck.h>" >&5
> -$as_echo_n "checking for VALGRIND_DISCARD in <valgrind/memcheck.h>... " >&6; }
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <valgrind/memcheck.h>
> -#ifndef VALGRIND_DISCARD
> -#error VALGRIND_DISCARD not defined
> -#endif
> -_ACEOF
> -if ac_fn_cxx_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 <memcheck.h>" >&5
> -$as_echo_n "checking for VALGRIND_DISCARD in <memcheck.h>... " >&6; }
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h. */
> -#include <memcheck.h>
> -#ifndef VALGRIND_DISCARD
> -#error VALGRIND_DISCARD not defined
> -#endif
> -_ACEOF
> -if ac_fn_cxx_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
> -
> if test x$ac_valgrind_checking != x ; then
>
> # Prepare PATH_SEPARATOR.
> @@ -7804,11 +7747,8 @@ else
> $as_echo "no" >&6; }
> fi
>
> - if test "x$valgrind_path" = "x" \
> - || (test $have_valgrind_h = no \
> - && test $gcc_cv_header_memcheck_h = no \
> - && test $gcc_cv_header_valgrind_memcheck_h = no); then
> - as_fn_error $? "*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h" "$LINENO" 5
> + if test "x$valgrind_path" = "x"; then
> + as_fn_error $? "*** Cannot find valgrind" "$LINENO" 5
> fi
> valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
> valgrind_command="$valgrind_path -q"
> @@ -7864,12 +7804,16 @@ else
> enable_valgrind_annotations=no
> fi
>
> +ac_fn_cxx_check_header_mongrel "$LINENO" "valgrind/memcheck.h" "ac_cv_header_valgrind_memcheck_h" "$ac_includes_default"
> +if test "x$ac_cv_header_valgrind_memcheck_h" = xyes; then :
> +
> +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 $? "*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h" "$LINENO" 5
> + if test $ac_cv_header_valgrind_memcheck_h = no; then
> + as_fn_error $? "*** Cannot find valgrind/memcheck.h" "$LINENO" 5
> fi
>
> $as_echo "#define ENABLE_VALGRIND_ANNOTATIONS 1" >>confdefs.h
> @@ -21602,7 +21546,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 21605 "configure"
> +#line 21549 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> @@ -21708,7 +21652,7 @@ else
> lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
> lt_status=$lt_dlunknown
> cat > conftest.$ac_ext <<_LT_EOF
> -#line 21711 "configure"
> +#line 21655 "configure"
> #include "confdefs.h"
>
> #if HAVE_DLFCN_H
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index d9a35069e3..0cf5fda318 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -778,49 +778,11 @@ if test x$ac_fold_checking != x ; then
> fi
> valgrind_path_defines=
> valgrind_command=
> -
> -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 <valgrind/memcheck.h>)
> -AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> - [[#include <valgrind/memcheck.h>
> -#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 <memcheck.h>)
> -AC_PREPROC_IFELSE([AC_LANG_SOURCE(
> - [[#include <memcheck.h>
> -#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
> -
> if test x$ac_valgrind_checking != x ; then
> AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
> [$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
> - if test "x$valgrind_path" = "x" \
> - || (test $have_valgrind_h = no \
> - && test $gcc_cv_header_memcheck_h = no \
> - && test $gcc_cv_header_valgrind_memcheck_h = no); then
> - AC_MSG_ERROR([*** Can't find both valgrind and valgrind/memcheck.h, memcheck.h or valgrind.h])
> + if test "x$valgrind_path" = "x"; then
> + AC_MSG_ERROR([*** Cannot find valgrind])
> fi
> valgrind_path_defines=-DVALGRIND_PATH='\"'$valgrind_path'\"'
> valgrind_command="$valgrind_path -q"
> @@ -869,12 +831,11 @@ AC_ARG_ENABLE(valgrind-annotations,
> [AS_HELP_STRING([--enable-valgrind-annotations],
> [enable valgrind runtime interaction])], [],
> [enable_valgrind_annotations=no])
> +AC_CHECK_HEADER(valgrind/memcheck.h)
> 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([*** Can't find valgrind/memcheck.h, memcheck.h or valgrind.h])
> + if test $ac_cv_header_valgrind_memcheck_h = no; then
> + AC_MSG_ERROR([*** Cannot find valgrind/memcheck.h])
> fi
> AC_DEFINE(ENABLE_VALGRIND_ANNOTATIONS, 1,
> [Define to get calls to the valgrind runtime enabled.])
> diff --git a/gcc/system.h b/gcc/system.h
> index e924152ad4..16db87bd5a 100644
> --- a/gcc/system.h
> +++ b/gcc/system.h
> @@ -1217,28 +1217,11 @@ helper_const_non_const_cast (const char *p)
> #endif
>
> #ifdef ENABLE_VALGRIND_ANNOTATIONS
> -# ifdef HAVE_VALGRIND_MEMCHECK_H
> -# include <valgrind/memcheck.h>
> -# elif defined HAVE_MEMCHECK_H
> -# include <memcheck.h>
> -# else
> -# include <valgrind.h>
> -# endif
> -/* Compatibility macros to let valgrind 3.1 work. */
> -# ifndef VALGRIND_MAKE_MEM_NOACCESS
> -# define VALGRIND_MAKE_MEM_NOACCESS VALGRIND_MAKE_NOACCESS
> -# endif
> -# ifndef VALGRIND_MAKE_MEM_DEFINED
> -# define VALGRIND_MAKE_MEM_DEFINED VALGRIND_MAKE_READABLE
> -# endif
> -# ifndef VALGRIND_MAKE_MEM_UNDEFINED
> -# define VALGRIND_MAKE_MEM_UNDEFINED VALGRIND_MAKE_WRITABLE
> -# endif
> +#include <valgrind/memcheck.h>
> #else
> -/* Avoid #ifdef:s when we can help it. */
> +/* VALGRIND_DISCARD unregisters the given block handle,
> + but our code misuses it for discarding annotations. */
> #define VALGRIND_DISCARD(x)
> -#define VALGRIND_MALLOCLIKE_BLOCK(w,x,y,z)
> -#define VALGRIND_FREELIKE_BLOCK(x,y)
> #endif
>
> /* Macros to temporarily ignore some warnings. */
> --
> 2.39.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-11-24 8:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 18:13 [PATCH 0/2] Clean up Valgrind configury Alexander Monakov
2023-11-23 18:13 ` [PATCH 1/2] libcpp: configure: drop unused Valgrind detection Alexander Monakov
2023-11-24 8:10 ` Richard Biener
2023-11-23 18:13 ` [PATCH 2/2] gcc: configure: drop Valgrind 3.1 compatibility Alexander Monakov
2023-11-24 8:10 ` Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).