Module: xenomai-forge
Branch: next
Commit: 9c1bfdc1ee62f28824287712e3ddfeae52f0f6e0
URL:    
http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=9c1bfdc1ee62f28824287712e3ddfeae52f0f6e0

Author: Philippe Gerum <r...@xenomai.org>
Date:   Wed May 14 10:11:05 2014 +0200

build: disable Valgrind API causing broken GCC output

Some GCC releases emit broken assembly code for Valgrind client calls (*):
detect this issue and disable the Valgrind API accordingly.

In addition, --disable-valgrind-client is introduced to allow for
turning off the client API unconditionally.

(*) Debian GCC 4.7.2-5 is prone to this.

---

 configure    |   84 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 configure.ac |   38 ++++++++++++++++++++++++--
 2 files changed, 111 insertions(+), 11 deletions(-)

diff --git a/configure b/configure
index f5c40eb..1b8b881 100755
--- a/configure
+++ b/configure
@@ -870,6 +870,7 @@ with_dbx_root
 with_docbook_xsl_root
 enable_verbose_latex
 enable_asciidoc
+enable_valgrind_client
 enable_dlopen_libs
 enable_tls
 with_testdir
@@ -1553,6 +1554,8 @@ Optional Features:
                           installation can not be found by configure).
   --enable-verbose-latex  Uses LaTeX non-stop mode
   --enable-asciidoc       Build Asciidoc documentation
+  --enable-valgrind-client
+                          Enable Valgrind client API
   --enable-dlopen-libs    Allow dynamic loading of Xenomai libraries
   --enable-tls            Enable thread local storage
   --enable-fortify        Enable support for applications compiled with
@@ -13870,6 +13873,78 @@ if test x${CONFIG_XENO_ASCIIDOC} = xy -a x"$W3M" = x ; 
then
    as_fn_error $? "Missing the w3m tool to generate the documentation" 
"$LINENO" 5
 fi
 
+
+ac_fn_c_check_header_mongrel "$LINENO" "valgrind/valgrind.h" 
"ac_cv_header_valgrind_valgrind_h" "$ac_includes_default"
+if test "x$ac_cv_header_valgrind_valgrind_h" = xyes; then :
+  CONFIG_XENO_VALGRIND_API=y
+fi
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Valgrind client API" >&5
+$as_echo_n "checking for Valgrind client API... " >&6; }
+# Check whether --enable-valgrind-client was given.
+if test "${enable_valgrind_client+set}" = set; then :
+  enableval=$enable_valgrind_client; case "$enableval" in
+       n | no) unset CONFIG_XENO_VALGRIND_API ;;
+       esac
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
${CONFIG_XENO_VALGRIND_API:-no}" >&5
+$as_echo "${CONFIG_XENO_VALGRIND_API:-no}" >&6; }
+
+if test \! x$CONFIG_XENO_VALGRIND_API = x ; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether GCC emits sane 
code for Valgrind calls" >&5
+$as_echo_n "checking whether GCC emits sane code for Valgrind calls... " >&6; }
+   if ${ac_cv_valgrind_client+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+   save_CFLAGS="$CFLAGS"
+   CFLAGS="-O0"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <valgrind/valgrind.h>
+int
+main ()
+{
+return RUNNING_ON_VALGRIND;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_valgrind_client=yes
+else
+  ac_cv_valgrind_client="no (DISABLING)"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   CFLAGS="$save_CFLAGS"
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext 
$LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+
+   if [ \! "$ac_cv_valgrind_client" = yes ]; then
+      unset CONFIG_XENO_VALGRIND_API
+   fi
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_valgrind_client" >&5
+$as_echo "$ac_cv_valgrind_client" >&6; }
+fi
+
+test x$CONFIG_XENO_VALGRIND_API = xy &&
+$as_echo "#define CONFIG_XENO_VALGRIND_API 1" >>confdefs.h
+
+
 for ac_header in mqueue.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "mqueue.h" "ac_cv_header_mqueue_h" 
"$ac_includes_default"
@@ -13882,15 +13957,6 @@ fi
 
 done
 
-ac_fn_c_check_header_mongrel "$LINENO" "valgrind/valgrind.h" 
"ac_cv_header_valgrind_valgrind_h" "$ac_includes_default"
-if test "x$ac_cv_header_valgrind_valgrind_h" = xyes; then :
-  CONFIG_XENO_VALGRIND_API=y
-fi
-
-
-test x$CONFIG_XENO_VALGRIND_API = xy &&
-$as_echo "#define CONFIG_XENO_VALGRIND_API 1" >>confdefs.h
-
 
 save_LIBS="$LIBS"
 LIBS="$LIBS -lrt -lpthread"
diff --git a/configure.ac b/configure.ac
index 125e5f1..49bab66 100644
--- a/configure.ac
+++ b/configure.ac
@@ -497,11 +497,45 @@ if test x${CONFIG_XENO_ASCIIDOC} = xy -a x"$W3M" = x ; 
then
    AC_MSG_ERROR([Missing the w3m tool to generate the documentation])
 fi
 
-dnl Determine whether some specific headers are present on this system.
-AC_CHECK_HEADERS(mqueue.h)
+dnl Check for Valgrind client API support.
+dnl Some GCC releases produce broken assembly code for Valgrind
+dnl client calls, so we check this too. --disable-valgrind-client
+dnl may be used to forcibly turn this API off.
+
 AC_CHECK_HEADER(valgrind/valgrind.h,CONFIG_XENO_VALGRIND_API=y)
+
+AC_MSG_CHECKING(for Valgrind client API)
+AC_ARG_ENABLE(valgrind-client,
+       AS_HELP_STRING([--enable-valgrind-client], [Enable Valgrind client 
API]),
+       [case "$enableval" in
+       n | no) unset CONFIG_XENO_VALGRIND_API ;;
+       esac])
+AC_MSG_RESULT(${CONFIG_XENO_VALGRIND_API:-no})
+
+if test \! x$CONFIG_XENO_VALGRIND_API = x ; then
+   AC_MSG_CHECKING([whether GCC emits sane code for Valgrind calls])
+   AC_CACHE_VAL(ac_cv_valgrind_client,
+   AC_LANG_SAVE
+   AC_LANG_C
+   save_CFLAGS="$CFLAGS"
+   CFLAGS="-O0"
+   [AC_TRY_COMPILE([#include <valgrind/valgrind.h>],
+   [return RUNNING_ON_VALGRIND;],
+   [ac_cv_valgrind_client=yes],
+   [ac_cv_valgrind_client="no (DISABLING)"])]
+   CFLAGS="$save_CFLAGS"
+   AC_LANG_RESTORE)
+   if [[ \! "$ac_cv_valgrind_client" = yes ]]; then
+      unset CONFIG_XENO_VALGRIND_API
+   fi
+   AC_MSG_RESULT([$ac_cv_valgrind_client])
+fi
+
 test x$CONFIG_XENO_VALGRIND_API = xy && 
AC_DEFINE(CONFIG_XENO_VALGRIND_API,1,[config])
 
+dnl Check for presence of some headers
+AC_CHECK_HEADERS(mqueue.h)
+
 dnl Check for presence of some routines we need
 save_LIBS="$LIBS"
 LIBS="$LIBS -lrt -lpthread"


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to