Better detect suitable libctf version
authorDodji Seketeli <dodji@redhat.com>
Mon, 9 Jan 2023 17:01:32 +0000 (18:01 +0100)
committerDodji Seketeli <dodji@redhat.com>
Mon, 9 Jan 2023 17:01:32 +0000 (18:01 +0100)
On some el9 distros, the version of libctf installed might not have
all the necessary features for the libabigail CTF reader, leading to
compilation errors due to missing types from the ctf-api.h header
file.  For instance, the ctf-api.h on some of those distros lacks the
definition of the type struct ctf_dict_t.

This patch adds a configure test for that struct and disables the CTF
support if that type is absent.

* configure.ac: If the "struct ctf_dict_t" type is not present in
the version of ctf-api.h that is present, then switch the support
of CTF off.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
configure.ac

index d289602021b8b0ee17ea455d92b55864d8a35d95..d19c2f968ea1e08655227b2446f515af81077fd3 100644 (file)
@@ -333,6 +333,23 @@ if test x$ENABLE_CTF != xno; then
        AC_CHECK_LIB(ctf, ctf_open, [LIBCTF=yes], [LIBCTF=no])
   fi
 
+  if test x$LIBCTF = xyes; then
+    dnl Test if struct btf_enum64 is present.
+    AC_CHECK_TYPE([struct ctf_dict_t],
+                 [HAVE_CTF_DICT_T=yes],
+                 [HAVE_CTF_DICT_T=no],
+                 [#include <ctf-api.h>])
+
+    if test x$HAVE_CTF_DICT_T = xyes; then
+      AC_DEFINE([HAVE_CTF_DICT_T], 1, [struct ctf_dict_t is present])
+    fi
+  fi
+
+  if test x$HAVE_CTF_DICT_T = xno; then
+     AC_MSG_NOTICE([Some needed data structures are missing from ctf-api.h. Disabling CTF support.])
+     LIBCTF=no
+  fi
+
   if test x$LIBCTF = xyes; then
     AC_MSG_NOTICE([CTF support enabled])
     AC_DEFINE([WITH_CTF], 1,
@@ -340,7 +357,7 @@ if test x$ENABLE_CTF != xno; then
     CTF_LIBS=-lctf
     ENABLE_CTF=yes
   else
-    AC_MSG_NOTICE([no libctf found, CTF support was disabled])
+    AC_MSG_NOTICE([no suitable libctf found, CTF support was disabled])
     ENABLE_CTF=no
   fi
 fi