gnu: postgresql-13: Fix building on riscv64-linux.
* gnu/packages/databases.scm (postgresql-13)[arguments]: Add phase when buidling for riscv64-linux to apply a patch. [native-inputs]: When building for riscv64-linux add patch and patch file. * gnu/packages/patches/postgresql-riscv-spinlocks.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it.
This commit is contained in:
parent
bc11d9ceb2
commit
781dd2de23
|
@ -1644,6 +1644,7 @@ dist_patch_DATA = \
|
||||||
%D%/packages/patches/portaudio-audacity-compat.patch \
|
%D%/packages/patches/portaudio-audacity-compat.patch \
|
||||||
%D%/packages/patches/portmidi-modular-build.patch \
|
%D%/packages/patches/portmidi-modular-build.patch \
|
||||||
%D%/packages/patches/postgresql-disable-resolve_symlinks.patch \
|
%D%/packages/patches/postgresql-disable-resolve_symlinks.patch \
|
||||||
|
%D%/packages/patches/postgresql-riscv-spinlocks.patch \
|
||||||
%D%/packages/patches/procmail-ambiguous-getline-debian.patch \
|
%D%/packages/patches/procmail-ambiguous-getline-debian.patch \
|
||||||
%D%/packages/patches/procmail-CVE-2014-3618.patch \
|
%D%/packages/patches/procmail-CVE-2014-3618.patch \
|
||||||
%D%/packages/patches/procmail-CVE-2017-16844.patch \
|
%D%/packages/patches/procmail-CVE-2017-16844.patch \
|
||||||
|
|
|
@ -1278,7 +1278,29 @@ (define-public postgresql-13
|
||||||
version "/postgresql-" version ".tar.bz2"))
|
version "/postgresql-" version ".tar.bz2"))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"1kf0gcsrl5n25rjlvkh87aywmn28kbwvakm5c7j1qpr4j01y34za"))))))
|
"1kf0gcsrl5n25rjlvkh87aywmn28kbwvakm5c7j1qpr4j01y34za"))))
|
||||||
|
(arguments
|
||||||
|
(if (target-riscv64?)
|
||||||
|
`(,@(substitute-keyword-arguments (package-arguments postgresql-14)
|
||||||
|
((#:phases phases)
|
||||||
|
#~(modify-phases #$phases
|
||||||
|
(add-after 'unpack 'apply-riscv-spinlock-patch
|
||||||
|
;; The patch is applied in this custom phase and not via the
|
||||||
|
;; "origin" object above to avoid rebuilding a large number
|
||||||
|
;; of packages on other platforms.
|
||||||
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
|
(let ((patch-file
|
||||||
|
#$(local-file
|
||||||
|
(search-patch
|
||||||
|
"postgresql-riscv-spinlocks.patch"))))
|
||||||
|
(invoke "patch" "-p1" "-i" patch-file))))))))
|
||||||
|
`(,@(package-arguments postgresql-14))))
|
||||||
|
(native-inputs
|
||||||
|
(if (target-riscv64?)
|
||||||
|
(list
|
||||||
|
(local-file (search-patch "postgresql-riscv-spinlocks.patch"))
|
||||||
|
patch)
|
||||||
|
'()))))
|
||||||
|
|
||||||
(define-public postgresql-11
|
(define-public postgresql-11
|
||||||
(package
|
(package
|
||||||
|
|
41
gnu/packages/patches/postgresql-riscv-spinlocks.patch
Normal file
41
gnu/packages/patches/postgresql-riscv-spinlocks.patch
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
https://www.postgresql.org/message-id/dea97b6d-f55f-1f6d-9109-504aa7dfa421@gentoo.org
|
||||||
|
|
||||||
|
The attached patch adds native spinlock support to PostgreSQL on RISC-V
|
||||||
|
systems. As suspected by Richard W.M. Jones of Red Hat back in 2016, the
|
||||||
|
__sync_lock_test_and_set() approach applied on arm and arm64 works here
|
||||||
|
as well.
|
||||||
|
|
||||||
|
|
||||||
|
Tested against PostgreSQL 13.3 on a physical rv64gc system (BeagleV
|
||||||
|
Starlight beta board) - builds and installs fine, all tests pass. From
|
||||||
|
what I can see in gcc documentation this should in theory work on rv32
|
||||||
|
(and possibly rv128) as well, therefore the patch as it stands covers
|
||||||
|
all RISC-V systems (i.e. doesn't check the value of __risc_xlen) - but I
|
||||||
|
haven't confirmed this experimentally.
|
||||||
|
|
||||||
|
--- a/src/include/storage/s_lock.h
|
||||||
|
+++ b/src/include/storage/s_lock.h
|
||||||
|
@@ -315,12 +315,12 @@
|
||||||
|
#endif /* __ia64__ || __ia64 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
- * On ARM and ARM64, we use __sync_lock_test_and_set(int *, int) if available.
|
||||||
|
+ * On ARM, ARM64 and RISC-V, we use __sync_lock_test_and_set(int *, int) if available.
|
||||||
|
*
|
||||||
|
* We use the int-width variant of the builtin because it works on more chips
|
||||||
|
* than other widths.
|
||||||
|
*/
|
||||||
|
-#if defined(__arm__) || defined(__arm) || defined(__aarch64__) || defined(__aarch64)
|
||||||
|
+#if defined(__arm__) || defined(__arm) || defined(__aarch64__) || defined(__aarch64) || defined(__riscv)
|
||||||
|
#ifdef HAVE_GCC__SYNC_INT32_TAS
|
||||||
|
#define HAS_TEST_AND_SET
|
||||||
|
|
||||||
|
@@ -337,7 +337,7 @@
|
||||||
|
#define S_UNLOCK(lock) __sync_lock_release(lock)
|
||||||
|
|
||||||
|
#endif /* HAVE_GCC__SYNC_INT32_TAS */
|
||||||
|
-#endif /* __arm__ || __arm || __aarch64__ || __aarch64 */
|
||||||
|
+#endif /* __arm__ || __arm || __aarch64__ || __aarch64 || __riscv */
|
||||||
|
|
||||||
|
|
||||||
|
/* S/390 and S/390x Linux (32- and 64-bit zSeries) */
|
Loading…
Reference in a new issue