some LLVM function checks missing in meson

Started by Peter Eisentrautalmost 2 years ago4 messages
#1Peter Eisentraut
peter@eisentraut.org

I have been checking the pg_config.h generated by configure and meson to
see if there is anything materially different. I found that

HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER and
HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER

are missing on the meson side.

Something like the below would appear to fix that:

diff --git a/meson.build b/meson.build
index 43fad5323c0..cdfd31377d1 100644
--- a/meson.build
+++ b/meson.build
@@ -2301,6 +2301,14 @@ decl_checks += [
    ['pwritev', 'sys/uio.h'],
  ]
+# Check presence of some optional LLVM functions.
+if llvm.found()
+  decl_checks += [
+    ['LLVMCreateGDBRegistrationListener', 'llvm-c/ExecutionEngine.h'],
+    ['LLVMCreatePerfJITEventListener', 'llvm-c/ExecutionEngine.h'],
+  ]
+endif
+
  foreach c : decl_checks
    func = c.get(0)
    header = c.get(1)

I don't know what these functions do, but the symbols are used in the
source code. Thoughts?

#2Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Peter Eisentraut (#1)
Re: some LLVM function checks missing in meson

On 11/04/2024 18:26, Peter Eisentraut wrote:

I have been checking the pg_config.h generated by configure and meson to
see if there is anything materially different. I found that

HAVE_DECL_LLVMCREATEGDBREGISTRATIONLISTENER and
HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER

are missing on the meson side.

Something like the below would appear to fix that:

diff --git a/meson.build b/meson.build
index 43fad5323c0..cdfd31377d1 100644
--- a/meson.build
+++ b/meson.build
@@ -2301,6 +2301,14 @@ decl_checks += [
['pwritev', 'sys/uio.h'],
]
+# Check presence of some optional LLVM functions.
+if llvm.found()
+  decl_checks += [
+    ['LLVMCreateGDBRegistrationListener', 'llvm-c/ExecutionEngine.h'],
+    ['LLVMCreatePerfJITEventListener', 'llvm-c/ExecutionEngine.h'],
+  ]
+endif
+
foreach c : decl_checks
func = c.get(0)
header = c.get(1)

I don't know what these functions do, but the symbols are used in the
source code. Thoughts?

+1. I also don't know what they do, but clearly the configure and meson
checks should be in sync.

There's also this in llvmjit.c:

if (llvm_opt3_orc)
{
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) && HAVE_DECL_LLVMORCREGISTERPERF
if (jit_profiling_support)
LLVMOrcUnregisterPerf(llvm_opt3_orc);
#endif
LLVMOrcDisposeInstance(llvm_opt3_orc);
llvm_opt3_orc = NULL;
}

if (llvm_opt0_orc)
{
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) && HAVE_DECL_LLVMORCREGISTERPERF
if (jit_profiling_support)
LLVMOrcUnregisterPerf(llvm_opt0_orc);
#endif
LLVMOrcDisposeInstance(llvm_opt0_orc);
llvm_opt0_orc = NULL;
}
}

The autoconf test that set HAVE_DECL_LLVMORCREGISTERPERF was removed in
commit e9a9843e13. I believe that's a leftover that should also have
been removed.

--
Heikki Linnakangas
Neon (https://neon.tech)

#3Peter Eisentraut
peter@eisentraut.org
In reply to: Heikki Linnakangas (#2)
Re: some LLVM function checks missing in meson

On 13.04.24 10:25, Heikki Linnakangas wrote:

There's also this in llvmjit.c:

        if (llvm_opt3_orc)
        {
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) &&
HAVE_DECL_LLVMORCREGISTERPERF
            if (jit_profiling_support)
                LLVMOrcUnregisterPerf(llvm_opt3_orc);
#endif
            LLVMOrcDisposeInstance(llvm_opt3_orc);
            llvm_opt3_orc = NULL;
        }

        if (llvm_opt0_orc)
        {
#if defined(HAVE_DECL_LLVMORCREGISTERPERF) &&
HAVE_DECL_LLVMORCREGISTERPERF
            if (jit_profiling_support)
                LLVMOrcUnregisterPerf(llvm_opt0_orc);
#endif
            LLVMOrcDisposeInstance(llvm_opt0_orc);
            llvm_opt0_orc = NULL;
        }
    }

The autoconf test that set HAVE_DECL_LLVMORCREGISTERPERF was removed in
commit e9a9843e13. I believe that's a leftover that should also have
been removed.

Right, that was clearly forgotten. I have removed the dead code.

#4Peter Eisentraut
peter@eisentraut.org
In reply to: Heikki Linnakangas (#2)
Re: some LLVM function checks missing in meson

On 13.04.24 10:25, Heikki Linnakangas wrote:

Something like the below would appear to fix that:

diff --git a/meson.build b/meson.build
index 43fad5323c0..cdfd31377d1 100644
--- a/meson.build
+++ b/meson.build
@@ -2301,6 +2301,14 @@ decl_checks += [
     ['pwritev', 'sys/uio.h'],
   ]
+# Check presence of some optional LLVM functions.
+if llvm.found()
+  decl_checks += [
+    ['LLVMCreateGDBRegistrationListener', 'llvm-c/ExecutionEngine.h'],
+    ['LLVMCreatePerfJITEventListener', 'llvm-c/ExecutionEngine.h'],
+  ]
+endif
+
   foreach c : decl_checks
     func = c.get(0)
     header = c.get(1)

I don't know what these functions do, but the symbols are used in the
source code.  Thoughts?

+1. I also don't know what they do, but clearly the configure and meson
checks should be in sync.

Committed that, too.