In many jit related bug reports, one of the first questions is often
"which llvm version is used". How about adding it into the
PG_VERSION_STR, similar to the gcc version?
>From 9a4404c0df92f96ab98fca3ff0d7952287c30ece Mon Sep 17 00:00:00 2001
From: Dmitrii Dolgov <9erthali...@gmail.com>
Date: Tue, 20 Aug 2024 22:54:43 +0200
Subject: [PATCH v1] Add llvm version to the PG_VERSION_STR

If built with llvm, add llvm version into the version string. This
should help to get more relevant information in bug reports about JIT.
---
 configure.ac | 8 +++++++-
 meson.build  | 8 +++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index 4e279c4bd6..3b483ad401 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2421,8 +2421,14 @@ else
   cc_string=$CC
 fi
 
+if test "$with_llvm" = yes ; then
+    llvm_string=", llvm $pgac_llvm_version"
+else
+    llvm_string=""
+fi
+
 AC_DEFINE_UNQUOTED(PG_VERSION_STR,
-                   ["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, 
`expr $ac_cv_sizeof_void_p \* 8`-bit"],
+                   ["PostgreSQL $PG_VERSION on $host, compiled by $cc_string, 
`expr $ac_cv_sizeof_void_p \* 8`-bit$llvm_string"],
                    [A string containing the version number, platform, and C 
compiler])
 
 # Supply a numeric version string for use by 3rd party add-ons
diff --git a/meson.build b/meson.build
index cd711c6d01..e4e4b0bc32 100644
--- a/meson.build
+++ b/meson.build
@@ -2759,12 +2759,18 @@ 
cdata.set('USE_@0@_SEMAPHORES'.format(sema_kind.to_upper()), 1)
 cdata.set('MEMSET_LOOP_LIMIT', memset_loop_limit)
 cdata.set_quoted('DLSUFFIX', dlsuffix)
 
+if llvm.found()
+  llvm_string = ', llvm @0@'.format(llvm.version())
+else
+  llvm_string = ''
+endif
 
 # built later than the rest of the version metadata, we need SIZEOF_VOID_P
 cdata.set_quoted('PG_VERSION_STR',
-  'PostgreSQL @0@ on @1@-@2@, compiled by @3@-@4@, @5@-bit'.format(
+  'PostgreSQL @0@ on @1@-@2@, compiled by @3@-@4@, @5@-bit@6@'.format(
     pg_version, host_machine.cpu_family(), host_system,
     cc.get_id(), cc.version(), cdata.get('SIZEOF_VOID_P') * 8,
+    llvm_string,
   )
 )
 

base-commit: 7ff9afbbd1df7c256024edb447eae7269c1bab03
-- 
2.45.1

Reply via email to