Update CTF's ctf_dict_t detection
authorDodji Seketeli <dodji@redhat.com>
Fri, 13 Jan 2023 15:29:19 +0000 (16:29 +0100)
committerDodji Seketeli <dodji@redhat.com>
Mon, 16 Jan 2023 09:07:32 +0000 (10:07 +0100)
As ctf_dict_t can be an opaque type depending on the version of
ctf-api.h, using AC_CHECK_TYPE won't work to detect it because that
macro invokes sizeof(ctf_dict_t).

With this change, we don't require that ctf_dict_t be fully defined.

* configure.ac: Use AC_COMPILE_IFELSE to try and compile a code
snippet that doesn't need that ctf_dict_t be fully defined.

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

index d19c2f968ea1e08655227b2446f515af81077fd3..4d214b1c3cc669a55926fb8c15eded916517155c 100644 (file)
@@ -334,11 +334,12 @@ if test x$ENABLE_CTF != xno; then
   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>])
+    dnl Test if struct struct ctf_dict_t is present.
+    AC_LANG(C++)
+    AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <ctf-api.h>
+                                       ctf_dict_t* c;]])],
+                     [HAVE_CTF_DICT_T=yes],
+                     [HAVE_CTF_DICT_T=no])
 
     if test x$HAVE_CTF_DICT_T = xyes; then
       AC_DEFINE([HAVE_CTF_DICT_T], 1, [struct ctf_dict_t is present])