Add support for RISC-V (riscv64)

Signed-off-by: David Abdurachmanov <david.abdurachmanov@gmail.com>
This commit is contained in:
David Abdurachmanov 2018-10-16 10:59:44 +02:00
parent f605c5c92b
commit 3608137c22
Signed by: davidlt
GPG Key ID: 7108702C938B13C1
2 changed files with 76 additions and 2 deletions

View File

@ -0,0 +1,67 @@
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
index 2123beb..edd9236 100644
--- a/build/moz.configure/init.configure
+++ b/build/moz.configure/init.configure
@@ -380,6 +380,9 @@ def split_triplet(triplet):
elif cpu.startswith('aarch64'):
canonical_cpu = 'aarch64'
endianness = 'little'
+ elif cpu.startswith('riscv64'):
+ canonical_cpu = 'riscv64'
+ endianness = 'little'
else:
die('Unknown CPU type: %s' % cpu)
diff --git a/mfbt/double-conversion/utils.h b/mfbt/double-conversion/utils.h
index 15dd4bf..4f37218 100644
--- a/mfbt/double-conversion/utils.h
+++ b/mfbt/double-conversion/utils.h
@@ -60,7 +60,8 @@
defined(__sparc__) || defined(__sparc) || defined(__s390__) || \
defined(__SH4__) || defined(__alpha__) || \
defined(_MIPS_ARCH_MIPS32R2) || \
- defined(__AARCH64EL__) || defined(__aarch64__)
+ defined(__AARCH64EL__) || defined(__aarch64__) || \
+ defined(__riscv)
#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1
#elif defined(_M_IX86) || defined(__i386__) || defined(__i386)
#if defined(_WIN32)
diff --git a/mfbt/tests/TestPoisonArea.cpp b/mfbt/tests/TestPoisonArea.cpp
index 6f1b61e..7063ab9 100644
--- a/mfbt/tests/TestPoisonArea.cpp
+++ b/mfbt/tests/TestPoisonArea.cpp
@@ -157,6 +157,14 @@
#elif defined __aarch64__
#define RETURN_INSTR 0xd65f03c0 /* ret */
+#elif defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64
+#if defined(__riscv_compressed)
+#define RETURN_INSTR 0x8082 /* ret */
+#define RETURN_INSTR_TYPE uint16_t
+#else
+#define RETURN_INSTR 0x00008067 /* ret */
+#endif
+
#elif defined __ia64
struct ia64_instr { uint32_t mI[4]; };
static const ia64_instr _return_instr =
diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py
index dfc7cf8..10035cb 100644
--- a/python/mozbuild/mozbuild/configure/constants.py
+++ b/python/mozbuild/mozbuild/configure/constants.py
@@ -48,6 +48,7 @@ CPU_bitness = {
'mips64': 64,
'ppc': 32,
'ppc64': 64,
+ 'riscv64': 64,
's390': 32,
's390x': 64,
'sparc': 32,
@@ -85,6 +86,7 @@ CPU_preprocessor_checks = OrderedDict((
('sparc', '__sparc__'),
('mips64', '__mips64'),
('mips32', '__mips__'),
+ ('riscv64', 'defined(__riscv) && defined(__riscv_xlen) && __riscv_xlen == 64'),
))
assert sorted(CPU_preprocessor_checks.keys()) == sorted(CPU.POSSIBLE_VALUES)

View File

@ -12,7 +12,7 @@
Name: mozjs%{major}
Version: 52.9.0
Release: 1%{?dist}
Release: 1.0.riscv64%{?dist}
Summary: SpiderMonkey JavaScript library
License: MPLv2.0 and MPLv1.1 and BSD and GPLv2+ and GPLv3+ and LGPLv2.1 and LGPLv2.1+ and AFL and ASL 2.0
@ -40,6 +40,9 @@ Patch26: build-icu-big-endian.patch
Patch36: build-missing-xlocale-h.patch
Patch304: mozilla-1253216.patch
# Add support for RISC-V (riscv64)
Patch400: firefox-52.7.2esr-add-riscv64.patch
BuildRequires: autoconf213
BuildRequires: gcc
BuildRequires: gcc-c++
@ -93,6 +96,7 @@ pushd ../..
%endif
%patch304 -p1 -b .1253216
%patch400 -p1 -b .riscv64
# make sure we don't ever accidentally link against bundled security libs
rm -rf security/
@ -123,7 +127,7 @@ autoconf-2.13
%ifarch s390 s390x
--disable-jemalloc \
%endif
%ifarch %{arm} aarch64 ppc %{power64}
%ifarch %{arm} aarch64 ppc %{power64} riscv64
--disable-ion
%endif
@ -184,6 +188,9 @@ ln -s libmozjs-%{major}.so.0 %{buildroot}%{_libdir}/libmozjs-%{major}.so
%{_includedir}/mozjs-%{major}/
%changelog
* Tue Oct 16 2018 David Abdurachmanov <david.abdurachmanov@gmail.com> - 52.9.0-1.0.riscv64
- Add support for RISC-V (riscv64)
* Wed Jul 25 2018 Kalev Lember <klember@redhat.com> - 52.9.0-1
- Update to 52.9.0