From 98349071bcdf65347f87d55a9b868338a1287f2f Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Mon, 20 Apr 2020 11:00:53 +0300 Subject: [PATCH] Fix atomic detection for RISC-V (riscv64) See: https://github.com/ruby/ruby/commit/abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2 https://bugs.ruby-lang.org/issues/16800 https://bugs.ruby-lang.org/issues/16774 Signed-off-by: David Abdurachmanov --- ...e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch | 37 +++++++++++++++++++ ruby-2.6.5-disable-assert.patch | 13 ------- ruby.spec | 2 +- 3 files changed, 38 insertions(+), 14 deletions(-) create mode 100644 abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch delete mode 100644 ruby-2.6.5-disable-assert.patch diff --git a/abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch b/abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch new file mode 100644 index 0000000..b62b5cb --- /dev/null +++ b/abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch @@ -0,0 +1,37 @@ +From abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab +Date: Fri, 10 Apr 2020 15:34:52 +0200 +Subject: [PATCH] Don't require sub-word atomics + +On some architectures (like RISC-V) sub-word atomics are only available +when linking against -latomic, but the configure script doesn't do that, +causing the atomic checks to fail and the resulting ruby binary is +non-functional. Ruby does not use sub-word atomic operations, rb_atomic_t +is defined to unsigned int, so use unsigned int when checking for atomic +operations. +--- + configure.ac | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/configure.ac b/configure.ac +index 7c12b9e5fb94..ba86deffbebb 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -1498,7 +1498,7 @@ AS_IF([test "$GCC" = yes], [ + ]) + + AC_CACHE_CHECK([for __atomic builtins], [rb_cv_gcc_atomic_builtins], [ +- AC_TRY_LINK([unsigned char atomic_var;], ++ AC_TRY_LINK([unsigned int atomic_var;], + [ + __atomic_exchange_n(&atomic_var, 0, __ATOMIC_SEQ_CST); + __atomic_exchange_n(&atomic_var, 1, __ATOMIC_SEQ_CST); +@@ -1513,7 +1513,7 @@ AS_IF([test "$GCC" = yes], [ + ]) + + AC_CACHE_CHECK([for __sync builtins], [rb_cv_gcc_sync_builtins], [ +- AC_TRY_LINK([unsigned char atomic_var;], ++ AC_TRY_LINK([unsigned int atomic_var;], + [ + __sync_lock_test_and_set(&atomic_var, 0); + __sync_lock_test_and_set(&atomic_var, 1); diff --git a/ruby-2.6.5-disable-assert.patch b/ruby-2.6.5-disable-assert.patch deleted file mode 100644 index b93cc43..0000000 --- a/ruby-2.6.5-disable-assert.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/thread_pthread.c b/thread_pthread.c -index 670e917..d466d10 100644 ---- a/thread_pthread.c -+++ b/thread_pthread.c -@@ -1992,7 +1992,7 @@ rb_sigwait_fd_put(const rb_thread_t *th, int fd) - - VM_ASSERT(signal_self_pipe.normal[0] == fd); - old = ATOMIC_PTR_EXCHANGE(sigwait_th, THREAD_INVALID); -- if (old != th) assert(old == th); -+ /* if (old != th) assert(old == th); */ - } - - #ifndef HAVE_PPOLL diff --git a/ruby.spec b/ruby.spec index 7c34a1e..c929d0c 100644 --- a/ruby.spec +++ b/ruby.spec @@ -160,7 +160,7 @@ Patch13: ruby-2.8.0-remove-unneeded-gem-require-for-ipaddr.patch Patch22: ruby-2.6.0-config-support-include-directive.patch # Disable pthread assert on Linux RISC-V (riscv64) -Patch30: ruby-2.6.5-disable-assert.patch +Patch30: abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch Requires: %{name}-libs%{?_isa} = %{version}-%{release} Suggests: rubypick