335c0bc610
Spidermonkey is Mozilla's JavaScript engine written in C and C++. It is used in various Mozilla products, including Firefox, and is available under the MPL2. There are 10 patches currently required to properly cross-compile spidermonkey: 1) allow-newer-autoconf-versions - Spidermonkey is hardcoded to use Autoconf 2.13, which is from 1999! The reasoning behind using 2.13 is because newer versions of Autoconf do not work correctly with the custom m4 macros in the source code. However: Because we are building just the Spidermonkey engine instead of the entire Firefox package, newer versions of Autoconf work without issue. See: See: https://bugzilla.mozilla.org/show_bug.cgi?id=104642 for further explanation. 2) allow-building-in-tree - By default, spidermonkey must be configured and built out-of-tree, otherwise the following error occurs: FATAL ERROR PROCESSING MOZBUILD FILE ============================== The error occurred while processing the following file or one of the files it includes: js/src/shell/moz.build The error occurred when validating the result of the execution. The reported error is: The path specified in LOCAL_INCLUDES is not allowed: .. (resolved to js/src) Remove this check, as spidermonkey builds without issue in-tree. 3) allow-unknown-configuration-options - By default, if an unknown parameter is passed to configure, an error is raised. Replace the raise with a pass and continue. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1379540 4) fix-building-with-musl - The MIPS specific header <sgidefs.h> is not provided by musl. The Linux kernel headers <asm/sgidefs.h> provide the same definitions. 5) add-riscv-support - Submitted upstream: See: https://bugzilla.mozilla.org/show_bug.cgi?id=1318905 6) copy-headers-on-install-instead-of-symlinking - When installing, instead of linking the headers to the source directory, copy them. 7) ensure-proper-running-on-64-bit-and-32-bit-be-platforms - Taken from the Fedora RPM Applied upstream. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1488552 8) 0008-save-and-restore-non-volatile-x28-on-ARM64-for-generated-unboxed-obje - Taken from the Fedora RPM: Applied upstream. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1375074 9) save-x28-before-clobbering-it-in-the-regex-compiler - Taken from the Fedora RPM: Applied upstream. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1445907 10) always-use-the-equivalent-year-to-determine-the-time-zone - Taken from the Fedora RPM: Applied upstream. Fixes: https://bugzilla.mozilla.org/show_bug.cgi?id=1415202 Typically, The Firefox source tarball is used to build spidermonkey; however, this has two disadvantages: - It's large. The Firefox source tarball is over 250M. - It requires Autoconf 2.13 Instead, use a tarball with only the Spidermonkey source code in it with a pre-setup configure file. This tarball reduces the size to 31M and prevents the Autoconf 2.13 requirement. Signed-off-by: Adam Duskett <aduskett@greenlots.com> [Thomas: adjust how the libnspr arch dependency is handled] Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
122 lines
4.3 KiB
Diff
122 lines
4.3 KiB
Diff
From 64ad80e6d95871f17be4cd01da15581f41ac0b2b Mon Sep 17 00:00:00 2001
|
|
From: Stefan O'Rear <sorear2@gmail.com>
|
|
Date: Fri, 11 Nov 2016 21:10:34 -0700
|
|
Subject: [PATCH] Add RISC-V support
|
|
|
|
These changes allow spidermonkey to cross-compile for riscv64 and riscv32.
|
|
|
|
Upstream-status: Submitted
|
|
See: https://bugzilla.mozilla.org/show_bug.cgi?id=1318905
|
|
|
|
Signed-off-by: Stefan O'Rear <sorear2@gmail.com>
|
|
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
|
|
Signed-off-by: Adam Duskett <aduskett@gmail.com>
|
|
---
|
|
build/autoconf/config.guess | 3 +++
|
|
build/moz.configure/init.configure | 3 +++
|
|
js/src/jit/AtomicOperations.h | 2 ++
|
|
js/src/jit/none/AtomicOperations-feeling-lucky.h | 8 ++++++++
|
|
mfbt/tests/TestPoisonArea.cpp | 3 +++
|
|
python/mozbuild/mozbuild/configure/constants.py | 4 ++++
|
|
6 files changed, 23 insertions(+)
|
|
|
|
diff --git a/build/autoconf/config.guess b/build/autoconf/config.guess
|
|
index d5d667d4..1277a862 100755
|
|
--- a/build/autoconf/config.guess
|
|
+++ b/build/autoconf/config.guess
|
|
@@ -1029,6 +1029,9 @@ EOF
|
|
ppcle:Linux:*:*)
|
|
echo powerpcle-unknown-linux-${LIBC}
|
|
exit ;;
|
|
+ riscv32:Linux:*:* | riscv64:Linux:*:*)
|
|
+ echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
|
+ exit ;;
|
|
s390:Linux:*:* | s390x:Linux:*:*)
|
|
echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
|
|
exit ;;
|
|
diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure
|
|
index 83b8d705..ef33db50 100644
|
|
--- a/build/moz.configure/init.configure
|
|
+++ b/build/moz.configure/init.configure
|
|
@@ -676,6 +676,9 @@ def split_triplet(triplet, allow_unknown=False):
|
|
elif cpu == 'sh4':
|
|
canonical_cpu = 'sh4'
|
|
endianness = 'little'
|
|
+ elif cpu in ('riscv32', 'riscv64'):
|
|
+ canonical_cpu = cpu
|
|
+ endianness = 'little'
|
|
elif allow_unknown:
|
|
canonical_cpu = cpu
|
|
endianness = 'unknown'
|
|
diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h
|
|
index 3501e65b..fda0b148 100644
|
|
--- a/js/src/jit/AtomicOperations.h
|
|
+++ b/js/src/jit/AtomicOperations.h
|
|
@@ -393,6 +393,8 @@ inline bool AtomicOperations::isLockfreeJS(int32_t size) {
|
|
#include "jit/none/AtomicOperations-feeling-lucky.h"
|
|
#elif defined(__s390__) || defined(__s390x__)
|
|
#include "jit/none/AtomicOperations-feeling-lucky.h"
|
|
+#elif defined(__riscv)
|
|
+#include "jit/none/AtomicOperations-feeling-lucky.h"
|
|
#else
|
|
#error "No AtomicOperations support provided for this platform"
|
|
#endif
|
|
diff --git a/js/src/jit/none/AtomicOperations-feeling-lucky.h b/js/src/jit/none/AtomicOperations-feeling-lucky.h
|
|
index c0b43699..42b1f3e0 100644
|
|
--- a/js/src/jit/none/AtomicOperations-feeling-lucky.h
|
|
+++ b/js/src/jit/none/AtomicOperations-feeling-lucky.h
|
|
@@ -80,6 +80,14 @@
|
|
#define GNUC_COMPATIBLE
|
|
#endif
|
|
|
|
+#ifdef __riscv
|
|
+#define GNUC_COMPATIBLE
|
|
+#ifdef __riscv_xlen == 64
|
|
+#define HAS_64BIT_ATOMICS
|
|
+#define HAS_64BIT_LOCKFREE
|
|
+#endif
|
|
+#endif
|
|
+
|
|
// The default implementation tactic for gcc/clang is to use the newer
|
|
// __atomic intrinsics added for use in C++11 <atomic>. Where that
|
|
// isn't available, we use GCC's older __sync functions instead.
|
|
diff --git a/mfbt/tests/TestPoisonArea.cpp b/mfbt/tests/TestPoisonArea.cpp
|
|
index 06c24ed0..fba9263c 100644
|
|
--- a/mfbt/tests/TestPoisonArea.cpp
|
|
+++ b/mfbt/tests/TestPoisonArea.cpp
|
|
@@ -168,6 +168,9 @@ static const ia64_instr _return_instr =
|
|
#define RETURN_INSTR _return_instr
|
|
#define RETURN_INSTR_TYPE ia64_instr
|
|
|
|
+#elif defined __riscv
|
|
+#define RETURN_INSTR 0x80828082 /* ret; ret */
|
|
+
|
|
#else
|
|
#error "Need return instruction for this architecture"
|
|
#endif
|
|
diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py
|
|
index 33ae5a45..1067b6a4 100644
|
|
--- a/python/mozbuild/mozbuild/configure/constants.py
|
|
+++ b/python/mozbuild/mozbuild/configure/constants.py
|
|
@@ -50,6 +50,8 @@ CPU_bitness = {
|
|
'mips64': 64,
|
|
'ppc': 32,
|
|
'ppc64': 64,
|
|
+ 'riscv32': 32,
|
|
+ 'riscv64': 64,
|
|
's390': 32,
|
|
's390x': 64,
|
|
'sh4': 32,
|
|
@@ -82,6 +84,8 @@ CPU_preprocessor_checks = OrderedDict((
|
|
('s390', '__s390__'),
|
|
('ppc64', '__powerpc64__'),
|
|
('ppc', '__powerpc__'),
|
|
+ ('riscv32', '__riscv && __SIZEOF_POINTER__ == 4'),
|
|
+ ('riscv64', '__riscv && __SIZEOF_POINTER__ == 8'),
|
|
('Alpha', '__alpha__'),
|
|
('hppa', '__hppa__'),
|
|
('sparc64', '__sparc__ && __arch64__'),
|
|
--
|
|
2.23.0
|
|
|