Add support for riscv64

Signed-off-by: David Abdurachmanov <david.abdurachmanov@sifive.com>
This commit is contained in:
David Abdurachmanov 2020-11-30 15:28:11 +02:00
parent a4429badec
commit 57848e79a0
Signed by: davidlt
GPG Key ID: 8B7F1DA0E2C9FDBB
3 changed files with 71 additions and 1 deletions

View File

@ -0,0 +1,37 @@
From abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
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);

View File

@ -0,0 +1,13 @@
diff --git a/spec/ruby/core/process/fixtures/clocks.rb b/spec/ruby/core/process/fixtures/clocks.rb
index 7537cfa..c4c647a 100644
--- a/spec/ruby/core/process/fixtures/clocks.rb
+++ b/spec/ruby/core/process/fixtures/clocks.rb
@@ -34,7 +34,7 @@ module ProcessSpecs
end
# These clocks in practice on ARM on Linux do not seem to match their reported resolution.
- platform_is :armv7, :armv8, :aarch64 do
+ platform_is :armv7, :armv8, :aarch64, :riscv64 do
clocks = clocks.reject { |clock, value|
[:CLOCK_PROCESS_CPUTIME_ID, :CLOCK_THREAD_CPUTIME_ID, :CLOCK_MONOTONIC_RAW].include?(clock)
}

View File

@ -23,7 +23,7 @@
%global release 135 %global release 135
%{!?release_string:%define release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}%{?dist}} %{!?release_string:%define release_string %{?development_release:0.}%{release}%{?development_release:.%{development_release}}.0.riscv64%{?dist}}
# The RubyGems library has to stay out of Ruby directory tree, since the # The RubyGems library has to stay out of Ruby directory tree, since the
# RubyGems should be share by all Ruby implementations. # RubyGems should be share by all Ruby implementations.
@ -173,6 +173,14 @@ Patch19: ruby-2.7.1-Timeout-the-test_bug_reporter_add-witout-raising-err.patch
# https://github.com/ruby/ruby/pull/3393 # https://github.com/ruby/ruby/pull/3393
Patch20: ruby-3.0.0-preview1-Enable-arm64-optimizations-that-exist-for-power-x86.patch Patch20: ruby-3.0.0-preview1-Enable-arm64-optimizations-that-exist-for-power-x86.patch
# Disable pthread assert on Linux RISC-V (riscv64)
Patch30: abe2e7de4d1f2d5861d7c9ab9c7e778f2ee1dcd2.patch
# Same as for ARM.
# See: https://bugs.ruby-lang.org/issues/16007
# https://github.com/ruby/ruby/commit/324dd9d01f0c97631a2588f63231bcb651844cca
Patch31: ruby-2.7.1-disable-riscv64-clocks.patch
Requires: %{name}-libs%{?_isa} = %{version}-%{release} Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Suggests: rubypick Suggests: rubypick
Recommends: ruby(rubygems) >= %{rubygems_version} Recommends: ruby(rubygems) >= %{rubygems_version}
@ -589,6 +597,11 @@ rm -rf ext/fiddle/libffi*
%patch19 -p1 %patch19 -p1
%patch20 -p1 %patch20 -p1
%ifarch riscv64
%patch30 -p1
%patch31 -p1
%endif
# Provide an example of usage of the tapset: # Provide an example of usage of the tapset:
cp -a %{SOURCE3} . cp -a %{SOURCE3} .
@ -869,6 +882,10 @@ MSPECOPTS="$MSPECOPTS -P 'File.utime allows Time instances in the far future to
# https://bugs.ruby-lang.org/issues/16749 # https://bugs.ruby-lang.org/issues/16749
MSPECOPTS="$MSPECOPTS -P 'File.lchmod changes the file mode of the link and not of the file'" MSPECOPTS="$MSPECOPTS -P 'File.lchmod changes the file mode of the link and not of the file'"
%ifarch riscv64
%define test_timeout_scale 30
%endif
# Give an option to increase the timeout in tests. # Give an option to increase the timeout in tests.
# https://bugs.ruby-lang.org/issues/16921 # https://bugs.ruby-lang.org/issues/16921
%{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \ %{?test_timeout_scale:RUBY_TEST_TIMEOUT_SCALE="%{test_timeout_scale}"} \
@ -1285,6 +1302,9 @@ MSPECOPTS="$MSPECOPTS -P 'File.lchmod changes the file mode of the link and not
%changelog %changelog
* Mon Nov 30 2020 David Abdurachmanov <david.abdurachmanov@sifive.com> - 2.7.2-135.0.riscv64
- Fix for riscv64
* Tue Oct 13 2020 Vít Ondruch <vondruch@redhat.com> - 2.7.2-135 * Tue Oct 13 2020 Vít Ondruch <vondruch@redhat.com> - 2.7.2-135
- Upgrade to Ruby 2.7.2. - Upgrade to Ruby 2.7.2.