diff options
author | Jakub Jirutka <jakub@jirutka.cz> | 2021-12-18 23:09:03 +0100 |
---|---|---|
committer | Jakub Jirutka <jakub@jirutka.cz> | 2021-12-18 23:27:30 +0100 |
commit | a4bdd2eed699938660a3a942a674359ac92381e4 (patch) | |
tree | ac7267e0bf25548ff872637c110875a10af285ce | |
parent | 2c86739b695c9b47195b2cb07ea682319bb169ee (diff) | |
download | aports-a4bdd2eed699938660a3a942a674359ac92381e4.tar.gz aports-a4bdd2eed699938660a3a942a674359ac92381e4.tar.bz2 aports-a4bdd2eed699938660a3a942a674359ac92381e4.tar.xz |
main/postgresql14: fix JIT on x86 and make s390x workaround conditional
-rw-r--r-- | main/postgresql14/APKBUILD | 6 | ||||
-rw-r--r-- | main/postgresql14/jit-datalayout-mismatch-on-s390x-and-x86.patch (renamed from main/postgresql14/jit-datalayout-mismatch-on-s390x.patch) | 53 |
2 files changed, 35 insertions, 24 deletions
diff --git a/main/postgresql14/APKBUILD b/main/postgresql14/APKBUILD index 8cd1e19121..26ed71d517 100644 --- a/main/postgresql14/APKBUILD +++ b/main/postgresql14/APKBUILD @@ -3,7 +3,7 @@ # Contributor: Jakub Jirutka <jakub@jirutka.cz> _pkgname=postgresql pkgver=14.1 -pkgrel=6 +pkgrel=7 _majorver=${pkgver%%.*} # Should this aport provide libpq* and libecpg*? true/false # Exactly one postgresql aport must be the default one! @@ -75,7 +75,7 @@ source="https://ftp.postgresql.org/pub/source/v$pkgver/postgresql-$pkgver.tar.bz remove-libecpg_compat.patch czech-snowball-stemmer.patch make-split-headers.patch - jit-datalayout-mismatch-on-s390x.patch + jit-datalayout-mismatch-on-s390x-and-x86.patch pg_config-add-major-version.patch libpgport-pkglibdir.patch.txt external-libpq.patch.txt @@ -522,7 +522,7 @@ c4179fcd8b71791cdc41ea7b622cf82e9bd42ac1de66999234b98a83c0c508c79c492a9301274fe8 d8eb4274a54b94bed4a2ded7ae775c5a95ca0f051b831b859ccf78bf6d2ea6fe89a9a0611771f6ad85573995a7e3af1fdf5859e20cae3267a52239f12e1b61c3 remove-libecpg_compat.patch 673707b331cd09c105d18f39e83ec39371886d5d8cf706b6ebbd30ace294fa3377c391bea1ab409c001644c90ac718e3250cbc4acd9224bc0e7ac1f86c832424 czech-snowball-stemmer.patch 5262f4944844bccc839c4441570b9eb2e0792390234ebfdb8ebb7b83380ce5f5de84b038cb03045526da202a185af9c3972c2ae1b9e0e743a95c6e84f4621cf9 make-split-headers.patch -87f470bb8d08050dd955bd6f1da291891970027e6cd001452efc0bd6a57ac46187082393cd5910c289fc6e1daaf0967415393629379c07aed4e78b8e87e5fff7 jit-datalayout-mismatch-on-s390x.patch +c24986becfd73546a062612335e53b4da34829e42a0c30e85ed7481924f13b1fd0a0e5079d680905a52afea1e99f2210cc3692c529a34a74cd6961c88cce9163 jit-datalayout-mismatch-on-s390x-and-x86.patch 7790e4e4374f7bdc6b4484ba87a5fa709d30d3cbdce61ee7bf9c5dfce40cb51c7bd54ab42f4050fb48eede08ef573624d819128e57cc8c976e01202854740308 pg_config-add-major-version.patch f8ed2b7b96fd22cd87c982151e659d82bcae10033a97f403f7847fce6daa8fc580e998cfb3813af9cb59a12f0c6bcc276397c28b1fc48321eed8c7ba5f3f92ed libpgport-pkglibdir.patch.txt 6078defb3da67e7df96665cc130d32b69eebfcaf49d92eef368ea8eea8bb311fab56064c104bc97f53da9cd925301bef696b506af33e0b66d65bc6cd41ec7499 external-libpq.patch.txt diff --git a/main/postgresql14/jit-datalayout-mismatch-on-s390x.patch b/main/postgresql14/jit-datalayout-mismatch-on-s390x-and-x86.patch index bce5c61e15..807a5f1b76 100644 --- a/main/postgresql14/jit-datalayout-mismatch-on-s390x.patch +++ b/main/postgresql14/jit-datalayout-mismatch-on-s390x-and-x86.patch @@ -1,27 +1,34 @@ -Patch-Source: https://src.fedoraproject.org/rpms/postgresql/blob/f35/f/postgresql-datalayout-mismatch-on-s390.patch -From 0edaa982336823d4d7af8f10b91579fe0099ef3d Mon Sep 17 00:00:00 2001 From: Tom Stellard <tstellar@redhat.com> -Date: Tue, 20 Apr 2021 20:14:21 -0700 -Subject: [PATCH] jit: Workaround potential datalayout mismatch on s390x +From: Jakub Jirutka <jakub@jirutka.cz> +Date: Sat, 18 Dec 2021 23:09:03 +0100 +Subject: [PATCH] jit: Workaround datalayout mismatch on s390x and x86 -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. ---- - src/backend/jit/llvm/llvmjit.c | 46 ++++++++++++++++++++++++++++++++-- - 1 file changed, 44 insertions(+), 2 deletions(-) +This patch is based on https://src.fedoraproject.org/rpms/postgresql/blob/f35/f/postgresql-datalayout-mismatch-on-s390.patch. + +Original description: + +> 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. + +We encountered an analogous problem even on x86 (legacy 32bit arch). +However, I didn't wanna waste my time researching what exact CPU features +are problematic on this dead architecture, so I just disabled usage of any +host specific CPU features when creating the JIT on x86. And while I was on +it, I also conditioned the s390x workaround for s390x only. -jirutka diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c index 98a27f08bf..05b6438ba8 100644 --- a/src/backend/jit/llvm/llvmjit.c +++ b/src/backend/jit/llvm/llvmjit.c -@@ -776,6 +776,35 @@ llvm_compile_module(LLVMJitContext *context) +@@ -776,7 +776,38 @@ errhidecontext(true))); } -+/* ++#if defined(__s390__) || defined(__s390x__) + /* + * For the systemz target, LLVM uses a different datalayout for z13 and newer + * CPUs than it does for older CPUs. This can cause a mismatch in datalayouts + * in the case where the llvm_types_module is compiled with a pre-z13 CPU @@ -49,11 +56,13 @@ index 98a27f08bf..05b6438ba8 100644 + LLVMDisposeTargetData(llvm_layoutref); + return ret; +} ++#endif + - /* ++/* * Per session initialization. */ -@@ -785,6 +814,7 @@ llvm_session_initialize(void) + static void +@@ -785,6 +816,7 @@ MemoryContext oldcontext; char *error = NULL; char *cpu = NULL; @@ -61,26 +70,31 @@ index 98a27f08bf..05b6438ba8 100644 char *features = NULL; LLVMTargetMachineRef opt0_tm; LLVMTargetMachineRef opt3_tm; -@@ -816,10 +846,17 @@ llvm_session_initialize(void) +@@ -815,11 +847,22 @@ + * latter is needed because some CPU architectures default to enabling * features not all CPUs have (weird, huh). */ ++#if !defined(__i386__) && !defined(__i386) // XXX: quick workaround for 32-bit x86 cpu = LLVMGetHostCPUName(); - features = LLVMGetHostCPUFeatures(); + features = host_features = LLVMGetHostCPUFeatures(); elog(DEBUG2, "LLVMJIT detected CPU \"%s\", with features \"%s\"", cpu, features); ++#endif ++#if defined(__s390__) || defined(__s390x__) + if (needs_systemz_workaround()) + { + const char *no_vector =",-vector"; + features = malloc(sizeof(char) * (strlen(host_features) + strlen(no_vector) + 1)); + sprintf(features, "%s%s", host_features, no_vector); + } ++#endif + opt0_tm = LLVMCreateTargetMachine(llvm_targetref, llvm_triple, cpu, features, LLVMCodeGenLevelNone, -@@ -833,8 +870,13 @@ llvm_session_initialize(void) +@@ -833,8 +876,13 @@ LLVMDisposeMessage(cpu); cpu = NULL; @@ -95,6 +109,3 @@ index 98a27f08bf..05b6438ba8 100644 /* force symbols in main binary to be loaded */ LLVMLoadLibraryPermanently(NULL); --- -2.27.0 - |