aboutsummaryrefslogtreecommitdiffstats
path: root/community/postgresql12/jit-datalayout-mismatch-on-s390x.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/postgresql12/jit-datalayout-mismatch-on-s390x.patch')
-rw-r--r--community/postgresql12/jit-datalayout-mismatch-on-s390x.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/community/postgresql12/jit-datalayout-mismatch-on-s390x.patch b/community/postgresql12/jit-datalayout-mismatch-on-s390x.patch
new file mode 100644
index 00000000000..62905d77c99
--- /dev/null
+++ b/community/postgresql12/jit-datalayout-mismatch-on-s390x.patch
@@ -0,0 +1,30 @@
+From: Jakub Jirutka <jakub@jirutka.cz>
+Date: Sat, 18 Dec 2021 23:35:00 +0100
+Subject: [PATCH] jit: Workaround datalayout mismatch on s390x
+
+LLVM's s390x target uses a different datalayout for z13 and newer processors.
+If llvmjit_types.bc is compiled to target a processor older than z13, and
+then the JIT runs on a z13 or newer processor, then there will be a mismatch
+in datalayouts between llvmjit_types.bc and the JIT engine. This mismatch
+causes the JIT to fail at runtime.
+
+This patch is inspired by https://src.fedoraproject.org/rpms/postgresql/pull-request/29.
+We couldn't use https://src.fedoraproject.org/rpms/postgresql/blob/f35/f/postgresql-datalayout-mismatch-on-s390.patch
+because it doesn't compile on PostgreSQL 12 (llvm_types_module is undeclared).
+
+diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c
+--- a/src/backend/jit/llvm/llvmjit.c
++++ b/src/backend/jit/llvm/llvmjit.c
+@@ -780,10 +780,12 @@
+ * latter is needed because some CPU architectures default to enabling
+ * features not all CPUs have (weird, huh).
+ */
++#if !defined(__s390__) && !defined(__s390x__) // XXX: quick workaround for s390x
+ cpu = LLVMGetHostCPUName();
+ features = LLVMGetHostCPUFeatures();
+ elog(DEBUG2, "LLVMJIT detected CPU \"%s\", with features \"%s\"",
+ cpu, features);
++#endif
+
+ opt0_tm =
+ LLVMCreateTargetMachine(llvm_targetref, llvm_triple, cpu, features,