public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libcpp: Add missing config for --enable-valgrind-annotations [PR107691]
@ 2022-11-17 21:02 Bernhard Reutner-Fischer
  2022-11-18  8:41 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Bernhard Reutner-Fischer @ 2022-11-17 21:02 UTC (permalink / raw)
  To: gcc-patches; +Cc: Bernhard Reutner-Fischer, Bernhard Reutner-Fischer

---
ceb17928e5d1d5 copied (parts of) the valgrind annotation checks from gcc
to libcpp. The above copies the missing pieces to libcpp to diagnose
when libcpp is configured with --enable-valgrind-annotations but
valgrind is not installed.

Tested with --enable-valgrind-annotations without valgrind installed
where it fixes errors thrown by test(1). And once with valgrind
installed.
Ok for trunk?

libcpp/ChangeLog:

	PR preprocessor/107691
	* configure.ac: Add valgrind header checks.
	* configure: Regenerate.
---
 libcpp/configure.ac | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/libcpp/configure.ac b/libcpp/configure.ac
index 9b6042518e5..89ac99b04bd 100644
--- a/libcpp/configure.ac
+++ b/libcpp/configure.ac
@@ -226,6 +226,40 @@ 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])], [],
@@ -235,6 +269,7 @@ if test x$enable_valgrind_annotations != xno \
   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,
-- 
2.38.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libcpp: Add missing config for --enable-valgrind-annotations [PR107691]
  2022-11-17 21:02 [PATCH] libcpp: Add missing config for --enable-valgrind-annotations [PR107691] Bernhard Reutner-Fischer
@ 2022-11-18  8:41 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2022-11-18  8:41 UTC (permalink / raw)
  To: Bernhard Reutner-Fischer; +Cc: gcc-patches, Bernhard Reutner-Fischer

On Thu, Nov 17, 2022 at 10:04 PM Bernhard Reutner-Fischer via
Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>
> ---
> ceb17928e5d1d5 copied (parts of) the valgrind annotation checks from gcc
> to libcpp. The above copies the missing pieces to libcpp to diagnose
> when libcpp is configured with --enable-valgrind-annotations but
> valgrind is not installed.
>
> Tested with --enable-valgrind-annotations without valgrind installed
> where it fixes errors thrown by test(1). And once with valgrind
> installed.
> Ok for trunk?

OK.

> libcpp/ChangeLog:
>
>         PR preprocessor/107691
>         * configure.ac: Add valgrind header checks.
>         * configure: Regenerate.
> ---
>  libcpp/configure.ac | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/libcpp/configure.ac b/libcpp/configure.ac
> index 9b6042518e5..89ac99b04bd 100644
> --- a/libcpp/configure.ac
> +++ b/libcpp/configure.ac
> @@ -226,6 +226,40 @@ 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])], [],
> @@ -235,6 +269,7 @@ if test x$enable_valgrind_annotations != xno \
>    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,
> --
> 2.38.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-18  8:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 21:02 [PATCH] libcpp: Add missing config for --enable-valgrind-annotations [PR107691] Bernhard Reutner-Fischer
2022-11-18  8:41 ` 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).