[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
27/41: gnu: mozjs-60: Add support for riscv64-linux.
From: |
guix-commits |
Subject: |
27/41: gnu: mozjs-60: Add support for riscv64-linux. |
Date: |
Thu, 9 Sep 2021 08:39:36 -0400 (EDT) |
efraim pushed a commit to branch wip-riscv
in repository guix.
commit f9ab2ceb2269f72e5417b015257491a129027910
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Thu Aug 26 16:14:37 2021 +0300
gnu: mozjs-60: Add support for riscv64-linux.
* gnu/packages/gnuzilla.scm (mozjs-60)[source]: Add patch.
[arguments]: Add phase to update config scripts.
[inputs]: Add config.
* gnu/packages/patches/mozjs60-riscv64-support.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
gnu/local.mk | 1 +
gnu/packages/gnuzilla.scm | 12 +-
gnu/packages/patches/mozjs60-riscv64-support.patch | 122 +++++++++++++++++++++
3 files changed, 134 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index 07e6787..449652c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1461,6 +1461,7 @@ dist_patch_DATA =
\
%D%/packages/patches/mozjs38-shell-version.patch \
%D%/packages/patches/mozjs38-tracelogger.patch \
%D%/packages/patches/mozjs38-version-detection.patch \
+ %D%/packages/patches/mozjs60-riscv64-support.patch \
%D%/packages/patches/mrrescue-support-love-11.patch \
%D%/packages/patches/mtools-mformat-uninitialized.patch \
%D%/packages/patches/mumps-build-parallelism.patch \
diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm
index 147af81..bbf1150 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -363,7 +363,8 @@ in C/C++.")
(file-name (git-file-name "mozjs" version))
(sha256
(base32
- "1xl6avsj9gkgma71p56jzs7nasc767k3n1frnmri5pad4rj94bij"))))
+ "1xl6avsj9gkgma71p56jzs7nasc767k3n1frnmri5pad4rj94bij"))
+ (patches (search-patches "mozjs60-riscv64-support.patch"))))
(arguments
`(#:tests? #f ; FIXME: all tests pass, but then the check phase fails
anyway.
#:test-target "check-jstests"
@@ -399,6 +400,14 @@ in C/C++.")
(cons (string-append "--prefix=" out)
configure-flags))
#t)))
+ (add-after 'unpack 'update-config-scripts
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ (for-each (lambda (file)
+ (install-file
+ (search-input-file
+ (or native-inputs inputs)
+ (string-append "/bin/" file))
"build/autoconf"))
+ '("config.guess" "config.sub"))))
(add-after 'unpack 'disable-broken-tests
(lambda _
;; This test assumes that /bin exists and contains certain
@@ -408,6 +417,7 @@ in C/C++.")
(native-inputs
`(("autoconf" ,autoconf)
("automake" ,automake)
+ ("config" ,config)
("which" ,which)
("perl" ,perl)
("pkg-config" ,pkg-config)
diff --git a/gnu/packages/patches/mozjs60-riscv64-support.patch
b/gnu/packages/patches/mozjs60-riscv64-support.patch
new file mode 100644
index 0000000..c9fa2ba
--- /dev/null
+++ b/gnu/packages/patches/mozjs60-riscv64-support.patch
@@ -0,0 +1,122 @@
+This is a combination of several upstream patches which weren't accepted.
+They were proposed by Fedora for spidermonkey 52 and were ultimately
+accepted years later after some changes for a later version. It was
+adapted slightly from both sets of patches to apply cleanly to mozjs-60.
+
+https://bugzilla.mozilla.org/show_bug.cgi?id=1318905
+https://bug1318905.bmoattachments.org/attachment.cgi?id=8812602
+https://bug1318905.bmoattachments.org/attachment.cgi?id=8812603
+https://bug1318905.bmoattachments.org/attachment.cgi?id=8812604
+https://phabricator.services.mozilla.com/D78623
+https://phabricator.services.mozilla.com/D78624
+https://phabricator.services.mozilla.com/D78625
+
+
+diff --git a/build/moz.configure/init.configure
b/build/moz.configure/init.configure
+index 83b8d705..59131525 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.startswith('riscv64'):
++ canonical_cpu = 'riscv64'
++ 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 a8970b0d..6b947a3f 100644
+--- a/js/src/jit/AtomicOperations.h
++++ b/js/src/jit/AtomicOperations.h
+@@ -375,7 +375,7 @@ AtomicOperations::isLockfreeJS(int32_t size)
+ # endif
+ #elif defined(__ppc__) || defined(__PPC__)
+ # include "jit/none/AtomicOperations-feeling-lucky.h"
+-#elif defined(__sparc__)
++#elif defined(__sparc__) || defined(__riscv)
+ # include "jit/none/AtomicOperations-feeling-lucky.h"
+ #elif defined(__ppc64__) || defined(__PPC64__) || defined(__ppc64le__) ||
defined(__PPC64LE__)
+ # include "jit/none/AtomicOperations-feeling-lucky.h"
+diff --git a/js/src/jit/none/AtomicOperations-feeling-lucky.h
b/js/src/jit/none/AtomicOperations-feeling-lucky.h
+index da572284..6ce40c89 100644
+--- a/js/src/jit/none/AtomicOperations-feeling-lucky.h
++++ b/js/src/jit/none/AtomicOperations-feeling-lucky.h
+@@ -49,6 +49,12 @@
+ # define GNUC_COMPATIBLE
+ #endif
+
++#if defined(__riscv) && __riscv_xlen == 64
++# define HAS_64BIT_ATOMICS
++# define HAS_64BIT_LOCKFREE
++# define GNUC_COMPATIBLE
++#endif
++
+ #ifdef __sparc__
+ # define GNUC_COMPATIBLE
+ # ifdef __LP64__
+diff --git a/js/src/jit/none/MacroAssembler-none.h
b/js/src/jit/none/MacroAssembler-none.h
+index 80143dc8..b430fedb 100644
+--- a/js/src/jit/none/MacroAssembler-none.h
++++ b/js/src/jit/none/MacroAssembler-none.h
+@@ -402,6 +402,10 @@ class MacroAssemblerNone : public Assembler
+ #endif
+ };
+
++ struct AutoPrepareForPatching {
++ explicit AutoPrepareForPatching(MacroAssemblerNone&) {}
++ };
++
+ typedef MacroAssemblerNone MacroAssemblerSpecific;
+
+ class ABIArgGenerator
+diff --git a/mfbt/tests/TestPoisonArea.cpp b/mfbt/tests/TestPoisonArea.cpp
+index 06c24ed0..c3fed0df 100644
+--- a/mfbt/tests/TestPoisonArea.cpp
++++ b/mfbt/tests/TestPoisonArea.cpp
+@@ -160,6 +160,9 @@
+ #elif defined __aarch64__
+ #define RETURN_INSTR 0xd65f03c0 /* ret */
+
++#elif defined __riscv
++#define RETURN_INSTR 0x80828082 /* ret; ret */
++
+ #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 33ae5a45..11a01d3b 100644
+--- a/python/mozbuild/mozbuild/configure/constants.py
++++ b/python/mozbuild/mozbuild/configure/constants.py
+@@ -50,6 +50,7 @@ CPU_bitness = {
+ 'mips64': 64,
+ 'ppc': 32,
+ 'ppc64': 64,
++ 'riscv64': 64,
+ 's390': 32,
+ 's390x': 64,
+ 'sh4': 32,
+@@ -82,6 +84,7 @@ CPU_preprocessor_checks = OrderedDict((
+ ('s390', '__s390__'),
+ ('ppc64', '__powerpc64__'),
+ ('ppc', '__powerpc__'),
++ ('riscv64', '__riscv && __riscv_xlen == 64'),
+ ('Alpha', '__alpha__'),
+ ('hppa', '__hppa__'),
+ ('sparc64', '__sparc__ && __arch64__'),
+diff --git
a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+index cb7ff709..9da41adf 100755
+--- a/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
++++ b/python/mozbuild/mozbuild/test/configure/test_toolchain_configure.py
+@@ -1165,6 +1165,10 @@ class LinuxCrossCompileToolchainTest(BaseToolchainTest):
+ 'sh4-unknown-linux-gnu': little_endian + {
+ '__sh__': 1,
+ },
++ 'riscv64-unknown-linux-gnu': little_endian + {
++ '__riscv': 1,
++ '__riscv_xlen': 64,
++ },
+ }
+
+ PLATFORMS['powerpc64le-unknown-linux-gnu'] = \
- 24/41: gnu: libaio: Fix test suite on riscv64-linux., (continued)
- 24/41: gnu: libaio: Fix test suite on riscv64-linux., guix-commits, 2021/09/09
- 15/41: gnu: icu4c: Skip tests on riscv64-linux., guix-commits, 2021/09/09
- 36/41: gnu: postgresql: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 35/41: gnu: make-opensbi-package: Fix native building., guix-commits, 2021/09/09
- 05/41: gnu: guile: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 07/41: gnu: bdb: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 12/41: gnu: openblas: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 16/41: gnu: openblas-ilp64: Add riscv64-linux as a supported architecture., guix-commits, 2021/09/09
- 18/41: gnu: texlive-bin: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 23/41: gnu: Use libunwind-next for riscv64-linux., guix-commits, 2021/09/09
- 27/41: gnu: mozjs-60: Add support for riscv64-linux.,
guix-commits <=
- 37/41: gnu: isc-dhcp: Fix building on riscv64-linux., guix-commits, 2021/09/09
- 38/41: build-system/meson: Fix cross-building to riscv64-linux., guix-commits, 2021/09/09
- 40/41: gnu: Add u-boot-sifive-unmatched-bootloader., guix-commits, 2021/09/09
- 41/41: system: Add riscv64 support., guix-commits, 2021/09/09
- 10/41: gnu: openssl: Fix build on riscv64-linux., guix-commits, 2021/09/09
- 22/41: gnu: Add libunwind-next., guix-commits, 2021/09/09
- 31/41: gnu: make-opensbi-package: Adjust installed files., guix-commits, 2021/09/09
- 32/41: gnu: u-boot-sifive-unmatched: Build with opensbi., guix-commits, 2021/09/09
- 39/41: gnu: gtk+: Remove some more failing tests., guix-commits, 2021/09/09
- 29/41: gnu: nss: Adjust make-flags for riscv64-linux., guix-commits, 2021/09/09