Skip to content

Commit

Permalink
configure: Split valgrind test into pragma test and valgrind.h test
Browse files Browse the repository at this point in the history
Split the configure test that checks for valgrind into two, one
part checking whether we have the gcc pragma to disable unused-but-set
variables, and the other part checking for the existence of valgrind.h.
The first of these has to be compiled with -Werror and the second
does not and shouldn't generate any warnings.

This (a) allows us to enable "make errors in configure tests be
build failures" and (b) enables use of valgrind on systems with
a gcc which doesn't know about -Wunused-but-set-varibale, like
Debian squeeze.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
  • Loading branch information
pm215 authored and blueswirl committed Jul 31, 2012
1 parent 5e3bc71 commit 06d71fa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
23 changes: 21 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2872,15 +2872,30 @@ if compile_prog "" "" ; then
linux_magic_h=yes
fi

########################################
# check whether we can disable the -Wunused-but-set-variable
# option with a pragma (this is needed to silence a warning in
# some versions of the valgrind VALGRIND_STACK_DEREGISTER macro.)
# This test has to be compiled with -Werror as otherwise an
# unknown pragma is only a warning.
pragma_disable_unused_but_set=no
cat > $TMPC << EOF
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
int main(void) {
return 0;
}
EOF
if compile_prog "-Werror" "" ; then
pragma_disable_unused_but_set=yes
fi

########################################
# check if we have valgrind/valgrind.h

valgrind_h=no
cat > $TMPC << EOF
#include <valgrind/valgrind.h>
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
int main(void) {
VALGRIND_STACK_DEREGISTER(0);
return 0;
}
EOF
Expand Down Expand Up @@ -3397,6 +3412,10 @@ if test "$linux_magic_h" = "yes" ; then
echo "CONFIG_LINUX_MAGIC_H=y" >> $config_host_mak
fi

if test "$pragma_disable_unused_but_set" = "yes" ; then
echo "CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET=y" >> $config_host_mak
fi

if test "$valgrind_h" = "yes" ; then
echo "CONFIG_VALGRIND_H=y" >> $config_host_mak
fi
Expand Down
4 changes: 4 additions & 0 deletions coroutine-ucontext.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,18 @@ Coroutine *qemu_coroutine_new(void)
}

#ifdef CONFIG_VALGRIND_H
#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET
/* Work around an unused variable in the valgrind.h macro... */
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif
static inline void valgrind_stack_deregister(CoroutineUContext *co)
{
VALGRIND_STACK_DEREGISTER(co->valgrind_stack_id);
}
#ifdef CONFIG_PRAGMA_DISABLE_UNUSED_BUT_SET
#pragma GCC diagnostic error "-Wunused-but-set-variable"
#endif
#endif

void qemu_coroutine_delete(Coroutine *co_)
{
Expand Down

0 comments on commit 06d71fa

Please sign in to comment.