This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: valgrind GCC mods for memcheck.h
- From: Andreas Jaeger <aj at suse dot de>
- To: Hans-Peter Nilsson <hp at bitrange dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 02 Mar 2003 17:55:54 +0100
- Subject: Re: valgrind GCC mods for memcheck.h
- References: <Pine.BSF.4.44.0303021124040.18350-100000@dair.pair.com>
Hans-Peter Nilsson <hp at bitrange dot com> writes:
> On Sun, 2 Mar 2003, Andreas Jaeger wrote:
>> Hans-Peter Nilsson <hp at bitrange dot com> writes:
>> > I suggested to check whether VALGRIND_DISCARD is in memcheck.h.
>> > I'm cautious about there being another header by that name,
>> > since IMHO it's not well chosen. Perhaps I'm overcautious, but
>> > I want it on the table.
>>
>> How do I check for a macro using autoconf this way? Do you have some
>> suggestion to try?
>
> By reading the autoconf manual ;-) I found AC_TRY_COMPILE, which
I didn't find it directly, thanks for the hint.
> BTW also takes a list of include files. Perhaps there's
> something else hidden in the manual; I'm by no means an autoconf
> expert. I suggest something like
> AC_TRY_COMPILE (memcheck.h, [
> #ifndef VALGRIND_DISCARD
> error
> #endif
> ], AC_DEFINE(HAVE_MEMCHECK_H, 1,
> [Define if valgrind's memcheck.h header is installed.]))
I did something similar, see the appended patch.
>> Btw. bootstrapping does not work with current GCC anymore since the
>> usage of the valgrind macros generates warnings that are forbidden
>> now:
>>
>> /cvs/gcc/gcc/ggc-common.c: In function `ggc_realloc':
>> /cvs/gcc/gcc/ggc-common.c:157: warning: traditional C rejects string concatenation
>> /cvs/gcc/gcc/ggc-common.c:157: warning: ISO C forbids braced-groups within expressions
>
>> Any idea how to solve this issue?
>
> Maybe you could fixinclude valgrind.h and memcheck.h to use
> __extension__ or something. Or just turn off -Werror whenever
> --enable-checking=valgrind. Not worth anything harder IMHO.
Ok, I'll play around and then let's ask Julian,
Andreas
============================================================
Index: gcc/configure.in
--- gcc/configure.in 20 Feb 2003 23:38:06 -0000 1.644
+++ gcc/configure.in 2 Mar 2003 16:52:19 -0000
@@ -355,6 +355,15 @@ valgrind_command=
if test x$ac_checking_valgrind != x ; then
# 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 <memcheck.h>)
+ AC_TRY_COMPILE(
+ [#include <memcheck.h>],[
+#if ! (defined 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)
AC_CHECK_HEADER(valgrind.h, have_valgrind_h=yes, have_valgrind_h=no)
AM_PATH_PROG_WITH_TEST(valgrind_path, valgrind,
[$ac_dir/$ac_word --version | grep valgrind- >/dev/null 2>&1])
@@ -366,6 +375,10 @@ if test x$ac_checking_valgrind != x ; th
AC_DEFINE(ENABLE_VALGRIND_CHECKING, 1,
[Define if you want to run subprograms and generated programs
through valgrind (a memory checker). This is extremely expensive.])
+ 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
fi
AC_SUBST(valgrind_path_defines)
AC_SUBST(valgrind_command)
============================================================
Index: gcc/config.in
--- gcc/config.in 21 Jan 2003 00:12:52 -0000 1.149
+++ gcc/config.in 2 Mar 2003 16:52:19 -0000
@@ -347,6 +347,9 @@
through valgrind (a memory checker). This is extremely expensive. */
#undef ENABLE_VALGRIND_CHECKING
+/* Define if valgrind's memcheck.h header is installed. */
+#undef HAVE_MEMCHECK_H
+
/* Define if you want to use __cxa_atexit, rather than atexit, to
register C++ destructors for local statics and global objects.
This is essential for fully standards-compliant handling of
============================================================
Index: gcc/ggc-page.c
--- gcc/ggc-page.c 30 Jan 2003 18:14:06 -0000 1.61
+++ gcc/ggc-page.c 2 Mar 2003 16:52:20 -0000
@@ -32,7 +32,11 @@ Software Foundation, 59 Temple Place - S
#include "timevar.h"
#include "params.h"
#ifdef ENABLE_VALGRIND_CHECKING
-#include <valgrind.h>
+# ifdef HAVE_MEMCHECK_H
+# include <memcheck.h>
+# else
+# include <valgrind.h>
+# endif
#else
/* Avoid #ifdef:s when we can help it. */
#define VALGRIND_DISCARD(x)
============================================================
Index: gcc/ggc-common.c
--- gcc/ggc-common.c 23 Feb 2003 16:56:03 -0000 1.62
+++ gcc/ggc-common.c 2 Mar 2003 16:52:20 -0000
@@ -1,5 +1,6 @@
/* Simple garbage collection for the GNU compiler.
- Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000, 2001, 2002, 2003
+ Free Software Foundation, Inc.
This file is part of GCC.
@@ -38,7 +39,11 @@ Software Foundation, 59 Temple Place - S
#endif
#ifdef ENABLE_VALGRIND_CHECKING
-#include <valgrind.h>
+# ifdef HAVE_MEMCHECK_H
+# include <memcheck.h>
+# else
+# include <valgrind.h>
+# endif
#else
/* Avoid #ifdef:s when we can help it. */
#define VALGRIND_DISCARD(x)
============================================================
Index: gcc/cppfiles.c
--- gcc/cppfiles.c 1 Mar 2003 14:31:12 -0000 1.162
+++ gcc/cppfiles.c 2 Mar 2003 16:52:21 -0000
@@ -31,7 +31,11 @@ Foundation, 59 Temple Place - Suite 330,
#include "mkdeps.h"
#include "splay-tree.h"
#ifdef ENABLE_VALGRIND_CHECKING
-#include <valgrind.h>
+# ifdef HAVE_MEMCHECK_H
+# include <memcheck.h>
+# else
+# include <valgrind.h>
+# endif
#else
/* Avoid #ifdef:s when we can help it. */
#define VALGRIND_DISCARD(x)
--
Andreas Jaeger
SuSE Labs aj at suse dot de
private aj at arthur dot inka dot de
http://www.suse.de/~aj