guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

23/37: gnu: mozjs-60: Add support for riscv64-linux.


From: guix-commits
Subject: 23/37: gnu: mozjs-60: Add support for riscv64-linux.
Date: Tue, 2 Nov 2021 03:27:14 -0400 (EDT)

efraim pushed a commit to branch wip-riscv
in repository guix.

commit 6597ee971f9cbce5b4ecee744ad3617bd7b2c938
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 3c90bb2..7b32629 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1500,6 +1500,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 db1c9b0..f6f8967 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -367,7 +367,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"
@@ -425,6 +426,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
@@ -434,6 +443,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'] = \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]