configure: check for perf_event.h version
authorMarkus Metzger <markus.t.metzger@intel.com>
Tue, 28 Jul 2015 13:47:40 +0000 (15:47 +0200)
committerMarkus Metzger <markus.t.metzger@intel.com>
Fri, 7 Aug 2015 08:19:01 +0000 (10:19 +0200)
Intel(R) Processor Trace support requires a recent linux/perf_event.h header.

When GDB is built on an older system, Intel(R) Processor Trace will not be
available and there is no indication in the configure and build log as to
what went wrong.

Check for a compatible linux/perf_event.h at configure-time.

gdb/
* configure.ac: Check for PERF_ATTR_SIZE_VER5 in linux/perf_event.h
* configure: Regenerate.

gdb/ChangeLog
gdb/configure
gdb/configure.ac

index 2f62edd8cafb489a9724003955ccb014043ff917..105ab5a43dd746504392918fe11f190711843eb6 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-07  Markus Metzger  <markus.t.metzger@intel.com>
+
+       * configure.ac: Check for PERF_ATTR_SIZE_VER5 in linux/perf_event.h
+       * configure: Regenerate.
+
 2015-08-06  Yaakov Selkowitz  <yselkowi@redhat.com>
 
        * Makefile.in (LIBICONV): Define.
index 2949817372ceb65ecfc66a593ef4f426ec24b102..e420c03640ff4ef12ce67b023cf4e9d9e21e9bd8 100755 (executable)
@@ -1560,7 +1560,8 @@ Optional Packages:
                           (auto/yes/no/<python-program>)
   --with-guile[=GUILE]    include guile support
                           (auto/yes/no/<guile-version>/<pkg-config-program>)
-  --with-intel-pt         include Intel(R) Processor Trace support (auto/yes/no)
+  --with-intel-pt         include Intel(R) Processor Trace support
+                          (auto/yes/no)
   --with-libipt-prefix[=DIR]  search for libipt in DIR/include and DIR/lib
   --without-libipt-prefix     don't search for libipt in includedir and libdir
   --without-included-regex
@@ -10115,6 +10116,30 @@ if test "${with_intel_pt}" = no; then
 $as_echo "$as_me: WARNING: Intel(R) Processor Trace support disabled; some features may be unavailable." >&2;}
   HAVE_LIBIPT=no
 else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <linux/perf_event.h>
+#ifndef PERF_ATTR_SIZE_VER5
+# error
+#endif
+
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  perf_event=yes
+else
+  perf_event=no
+fi
+rm -f conftest.err conftest.$ac_ext
+  if test "$perf_event" != yes; then
+    if test "$with_intel_pt" = yes; then
+      as_fn_error "linux/perf_event.h missing or too old" "$LINENO" 5
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&5
+$as_echo "$as_me: WARNING: linux/perf_event.h missing or too old; some features may be unavailable." >&2;}
+    fi
+  fi
+
 
 
 
index 905c27b72fe5eb327822a4cbe2fb394f60d6c863..16bcd56c28f932ffd959d87796fe5d8b863ecf72 100644 (file)
@@ -1252,6 +1252,20 @@ if test "${with_intel_pt}" = no; then
   AC_MSG_WARN([Intel(R) Processor Trace support disabled; some features may be unavailable.])
   HAVE_LIBIPT=no
 else
+  AC_PREPROC_IFELSE(AC_LANG_SOURCE([[
+#include <linux/perf_event.h>
+#ifndef PERF_ATTR_SIZE_VER5
+# error
+#endif
+  ]]), [perf_event=yes], [perf_event=no])
+  if test "$perf_event" != yes; then
+    if test "$with_intel_pt" = yes; then
+      AC_MSG_ERROR([linux/perf_event.h missing or too old])
+    else
+      AC_MSG_WARN([linux/perf_event.h missing or too old; some features may be unavailable.])
+    fi
+  fi
+
   AC_LIB_HAVE_LINKFLAGS([ipt], [], [#include "intel-pt.h"], [pt_insn_alloc_decoder (0);])
   if test "$HAVE_LIBIPT" != yes; then
     if test "$with_intel_pt" = yes; then