1
0
Fork 0
mirror of https://gitlab.alpinelinux.org/alpine/aports.git synced 2025-07-14 19:59:55 +03:00
aports/testing/postgresql12/jit-datalayout-mismatch-on-s390x.patch
2023-10-04 00:45:44 +02:00

30 lines
1.4 KiB
Diff

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,