]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
jit: Fix jit_profiling_support when unavailable.
authorThomas Munro <tmunro@postgresql.org>
Wed, 31 Dec 2025 00:24:17 +0000 (13:24 +1300)
committerThomas Munro <tmunro@postgresql.org>
Wed, 31 Dec 2025 01:54:10 +0000 (14:54 +1300)
jit_profiling_support=true captures profile data for Linux perf.  On
other platforms, LLVMCreatePerfJITEventListener() returns NULL and the
attempt to register the listener would crash.

Fix by ignoring the setting in that case.  The documentation already
says that it only has an effect if perf support is present, and we
already did the same for older LLVM versions that lacked support.

No field reports, unsurprisingly for an obscure developer-oriented
setting.  Noticed in passing while working on commit 1a28b4b4.

Backpatch-through: 14
Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGJgB6gvrdDohgwLfCwzVQm%3DVMtb9m0vzQn%3DCwWn-kwG9w%40mail.gmail.com

src/backend/jit/llvm/llvmjit.c

index aadba6b6c35b96dacfe30bf890c18bc30f012591..4a9beddd688eaac13e0593fb40c6cd07d32a94cb 100644 (file)
@@ -1340,7 +1340,8 @@ llvm_create_object_layer(void *Ctx, LLVMOrcExecutionSessionRef ES, const char *T
        {
                LLVMJITEventListenerRef l = LLVMCreatePerfJITEventListener();
 
-               LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
+               if (l)
+                       LLVMOrcRTDyldObjectLinkingLayerRegisterJITEventListener(objlayer, l);
        }
 #endif