]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
configure.ac: explicitly check for asm/perf_regs.h presence users/serhei/try-perf-flags-configury
authorSerhei Makarov <serhei@serhei.io>
Mon, 24 Nov 2025 21:04:44 +0000 (16:04 -0500)
committerSerhei Makarov <serhei@serhei.io>
Mon, 24 Nov 2025 21:04:44 +0000 (16:04 -0500)
Not all Linux arches include <asm/perf_regs.h>. Checking for just
architecture (__x86__/__i386__) has turned out to be brittle, so
now we add configury.

* configure.ac: Introduce HAVE_PERF_REGS_H.
* backends/i386_initreg_sample.c: Guard asm/perf_regs.h include.
* backends/x86_64_initreg_sample.c: Ditto.
* backends/libebl_PERF_FLAGS.h: Ditto.
* src/stacktrace.c: Clarify that eu-stacktrace configury currently
  conditions the asm/perf_regs.h include on _ASM_X86_PERF_REGS_H.

backends/i386_initreg_sample.c
backends/libebl_PERF_FLAGS.h
backends/x86_64_initreg_sample.c
configure.ac
src/stacktrace.c

index d7d312b069032c97b7140f01bb9bdc5926f21486..52c81088f8addca54615fcad2ec541f5f23eb3c4 100644 (file)
@@ -34,7 +34,9 @@
 #include <assert.h>
 #if (defined __i386__ || defined __x86_64__) && defined(__linux__)
 # include <linux/perf_event.h>
-# include <asm/perf_regs.h>
+# ifdef HAVE_PERF_REGS_H
+#  include <asm/perf_regs.h>
+# endif
 #endif
 
 #define BACKEND i386_
index 51c20ea682f0bc10e8ac8251731cb0a860b991b1..5b5a8d78757dbb0ea6d0e1ba8d7aa8447ebcaceb 100644 (file)
@@ -33,8 +33,7 @@
 
 #if defined(__linux__)
 /* XXX Need to exclude __linux__ arches without perf_regs.h. */
-#if defined(__x86_64__) || defined(__i386__)
-/* || defined(other_architecture)... */
+#if defined HAVE_PERF_REGS_H
 # include <asm/perf_regs.h>
 #endif
 #endif
index 200a94a1faa2d0e93decf6c198408cf83136aaf4..c115fedf5671bb67df1b80c06ed24f05ed8b5db5 100644 (file)
@@ -34,7 +34,9 @@
 #include <assert.h>
 #if defined(__x86_64__) && defined(__linux__)
 # include <linux/perf_event.h>
-# include <asm/perf_regs.h>
+# ifdef HAVE_PERF_REGS_H
+#  include <asm/perf_regs.h>
+# endif
 #endif
 
 #define BACKEND x86_64_
index 58e58af2c58cd83aa32367ab1a13e2aa544a066d..ec40c7a3ffcc0af8090bb781fd8fc6b9903abfad 100644 (file)
@@ -971,6 +971,11 @@ AC_ARG_ENABLE(debuginfod-ima-cert-path,
 AC_SUBST(DEBUGINFOD_IMA_CERT_PATH, $default_debuginfod_ima_cert_path)
 AC_CONFIG_FILES([config/profile.sh config/profile.csh config/profile.fish])
 
+# check for asm/perf_regs.h, as it's completely absent on some architectures
+AH_TEMPLATE([HAVE_PERF_REGS_H], [Define to 1 if `asm/perf-regs.h` is provided by the system, 0 otherwise.])
+AC_CHECK_HEADER(asm/perf_regs.h,
+  [AC_DEFINE(HAVE_PERF_REGS_H)],[])
+
 # XXX Currently, eu-stacktrace can only work with sysprof/x86, hence:
 AC_ARG_ENABLE([stacktrace],AS_HELP_STRING([--enable-stacktrace], [Enable eu-stacktrace]))
 # check for x86, or more precisely _ASM_X86_PERF_REGS_H
index c330e64650432d28855d21a968acc22582837dcd..8f7325c530e36e83f3d65c6b0928efc9f144cf30 100644 (file)
@@ -83,7 +83,9 @@
 
 #include <linux/perf_event.h>
 
-/* TODO: Need to generalize the code beyond x86 architectures. */
+/* TODO: Need to generalize the code beyond x86 architectures.
+   eu-stacktrace currently disabled by configury
+   unless _ASM_X86_PERF_REGS_H is detected. */
 #include <asm/perf_regs.h>
 #ifndef _ASM_X86_PERF_REGS_H
 #error "eu-stacktrace is currently limited to x86 architectures"