aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2021-12-18 23:39:05 +0100
committerJakub Jirutka <jakub@jirutka.cz>2021-12-19 00:20:16 +0100
commitc7717448224303f7cff995139dcdac5f617c1d18 (patch)
treef5090d81fc7fc116652bb5c9009f34c2886dde84
parenteabac84d173824d8e7a76ec89b500da03d2ccd17 (diff)
downloadaports-c7717448224303f7cff995139dcdac5f617c1d18.tar.gz
aports-c7717448224303f7cff995139dcdac5f617c1d18.tar.bz2
aports-c7717448224303f7cff995139dcdac5f617c1d18.tar.xz
community/postgresql12: replace poor JIT patch with better one
Disable use of host specific CPU features when creating the JIT only on s390x, not on other architectures that are not affected by this issue. See 23236a1c555090fcb7d9f8c0813fb5110cf04b43
-rw-r--r--community/postgresql12/APKBUILD6
-rw-r--r--community/postgresql12/jit-Don-t-use-host-specific-CPU-or-features.patch27
-rw-r--r--community/postgresql12/jit-datalayout-mismatch-on-s390x.patch30
3 files changed, 33 insertions, 30 deletions
diff --git a/community/postgresql12/APKBUILD b/community/postgresql12/APKBUILD
index 3ffc4ae166..5731dd4927 100644
--- a/community/postgresql12/APKBUILD
+++ b/community/postgresql12/APKBUILD
@@ -3,7 +3,7 @@
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
_pkgname=postgresql
pkgver=12.9
-pkgrel=1
+pkgrel=2
_majorver=${pkgver%%.*}
# Should this aport provide libpq* and libecpg*? true/false
# Exactly one postgresql aport must be the default one!
@@ -73,7 +73,7 @@ source="https://ftp.postgresql.org/pub/source/v$pkgver/postgresql-$pkgver.tar.bz
disable-html-docs.patch
remove-libecpg_compat.patch
make-split-headers.patch
- jit-Don-t-use-host-specific-CPU-or-features.patch
+ jit-datalayout-mismatch-on-s390x.patch
pg_config-add-major-version.patch
libpgport-pkglibdir.patch.txt
external-libpq.patch.txt
@@ -479,7 +479,7 @@ c4179fcd8b71791cdc41ea7b622cf82e9bd42ac1de66999234b98a83c0c508c79c492a9301274fe8
2e33e1ae38d60e0daf3ed18e6eaa9ddf6762b4b1bb7e51f1d2690e3df9d602aa1a700e603ba3ee69314a75a963131c7dc67c1b1f8b7eb5564e9c4253e81a4db4 disable-html-docs.patch
d8eb4274a54b94bed4a2ded7ae775c5a95ca0f051b831b859ccf78bf6d2ea6fe89a9a0611771f6ad85573995a7e3af1fdf5859e20cae3267a52239f12e1b61c3 remove-libecpg_compat.patch
5262f4944844bccc839c4441570b9eb2e0792390234ebfdb8ebb7b83380ce5f5de84b038cb03045526da202a185af9c3972c2ae1b9e0e743a95c6e84f4621cf9 make-split-headers.patch
-b26d3c528065ff642e88c0616261f8a468904070ae24d52721f9f1f0f1329b3e9ceebfd477a4c40b87f2ae04ab7bb3c99892318b5fda373c90b84ccac06d88f6 jit-Don-t-use-host-specific-CPU-or-features.patch
+403f5afccda38ea666a9e813b0f41b5d9f93dede3c7d023b0d780b6b011af81b6bf32ba2d7769acc0404ec25b46978cb6c7a8a05063ccd0328ec69105c974b6f jit-datalayout-mismatch-on-s390x.patch
7790e4e4374f7bdc6b4484ba87a5fa709d30d3cbdce61ee7bf9c5dfce40cb51c7bd54ab42f4050fb48eede08ef573624d819128e57cc8c976e01202854740308 pg_config-add-major-version.patch
f8ed2b7b96fd22cd87c982151e659d82bcae10033a97f403f7847fce6daa8fc580e998cfb3813af9cb59a12f0c6bcc276397c28b1fc48321eed8c7ba5f3f92ed libpgport-pkglibdir.patch.txt
6078defb3da67e7df96665cc130d32b69eebfcaf49d92eef368ea8eea8bb311fab56064c104bc97f53da9cd925301bef696b506af33e0b66d65bc6cd41ec7499 external-libpq.patch.txt
diff --git a/community/postgresql12/jit-Don-t-use-host-specific-CPU-or-features.patch b/community/postgresql12/jit-Don-t-use-host-specific-CPU-or-features.patch
deleted file mode 100644
index 94076de622..0000000000
--- a/community/postgresql12/jit-Don-t-use-host-specific-CPU-or-features.patch
+++ /dev/null
@@ -1,27 +0,0 @@
---- a/src/backend/jit/llvm/llvmjit.c
-+++ b/src/backend/jit/llvm/llvmjit.c
-@@ -815,10 +815,20 @@
- * latter is needed because some CPU architectures default to enabling
- * features not all CPUs have (weird, huh).
- */
-- cpu = LLVMGetHostCPUName();
-- features = LLVMGetHostCPUFeatures();
-- elog(DEBUG2, "LLVMJIT detected CPU \"%s\", with features \"%s\"",
-- cpu, features);
-+
-+ /* FIXME: When compile code to pass to the JIT, we are pulling the
-+
-+ * datalayout from the llvmjit_types.bc, which is compiled at build
-+
-+ * type without any specifc CPU or feature flags. This can lead to
-+
-+ * a mismatch between the JIT's datalayout and the code's datalayout
-+
-+ * if we initialize the JIT for a specific CPU. So for now don't use
-+
-+ * any host specific cpu features when creating the JIT.
-+
-+ */
-
- opt0_tm =
- LLVMCreateTargetMachine(llvm_targetref, llvm_triple, cpu, features,
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 0000000000..62905d77c9
--- /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,