Skip to content
Permalink
Browse files
Unify SpiderMonkey1.8.5 build across .deb and .rpm
  • Loading branch information
wohali committed May 25, 2018
1 parent 3aae55d commit 1a0b467377000e46ee5673ae7a00b1ef44491108
Showing 30 changed files with 7,071 additions and 198 deletions.
@@ -10,18 +10,60 @@ While we're at it, we're going to make sure both platforms have both sets of pat

The hope is that [all of this goes away and is replaced by ChakraCore](https://github.com/apache/couchdb/issues/1334).

# External sources
# The great patchset merge

To keep things simpler to maintain, the exact same set of patches is used in building rpms and debs. (Symlinks aren't used, but could be. The contents of `js/rpm/SOURCES` and `js/debian/patches` are identical except for Debian's `series` file.) In general, the deb patches are of a higher quality, most of them originating from upstream.

With that in mind, the rpm patches as of js-1.8.5-20 (c7) were reviewed and handled thusly:

## Unique
* 0001-Make-js-config.h-multiarch-compatible.patch
* supports co-installation of 32-bit and 64-bit packages (though we only build 64-bit ones)
* js185-libedit.patch
* allows linking against libedit instead of readline
* we don't --enable-readline anyway, but it's a nice to have
* mozjs1.8.5-tag.patch
* the infamous 48 vs. 47 bit patch that started the entire process, and should fix aarch64 support
* ppc64le.patch
* improves some of the ifdefs in Platform.h, adds explicit ppc64le support to configure.in
* Makefile.in change needs backing out due to superior approach in debian's Bug-638056-Avoid-The-cacheFlush-support-is-missing-o.patch

## Superceded
* js-1.8.5-537701.patch
* js-1.8.5-64bit-big-endian.patch
* these are replaced by debian:64bit-big-endian.patch
* bz1027492-aarch64.patch
* js-1.8.5-secondary-jit.patch
* there is a much better approach in debian:Bug-638056-Avoid-The-cacheFlush-support-is-missing-o.patch
* js185-arm-nosoftfp.patch
* Debian's patches come from upstream, this one is RHEL specific
* debian: Bug-626035-Modify-the-way-arm-compiler-flags-are-set.patch
* debian: autoconf.patch

## Duplicate
* js185-destdir.patch

# Testing

On rpm systems, use `yum localinstall path/to/file.rpm path/to/next.rpm` to install local rpm files.

On deb systems, use `apt install path/to/file.deb path/to/next.deb` to install local deb files.


# External references

## Debian / Ubuntu / etc

* http://snapshot.debian.org/package/mozjs/1.8.5-1.0.0%2Bdfsg-8/ (last version before being dropped)
* and, specifically, http://snapshot.debian.org/archive/debian/20180330T054232Z/pool/main/m/mozjs/mozjs_1.8.5-1.0.0%2Bdfsg-8.debian.tar.xz
* https://www.debian.org/doc/manuals/maint-guide/

## RedHat / CentOS / Fedora / etc

* https://git.centos.org/summary/rpms!js.git
* https://bugs.centos.org/view.php?id=14720
* https://fedoraproject.org/wiki/Changes/aarch64-48bitVA
* https://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/index.html

## Other links we shouldn't lose track of

@@ -0,0 +1,72 @@
From 5017afb14474ef104719aaf56992f7c86475c42e Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Mon, 17 Mar 2014 13:48:01 -0400
Subject: [PATCH] Move JS_BYTES_PER_WORD out of config.h

Instead define it in terms of the already extant GNU C extension
__SIZEOF_POINTER__. This avoids multiarch conflicts when 32 and 64
bit packages of js are co-installed.
---
js/src/configure.in | 9 ---------
js/src/js-config.h.in | 1 -
js/src/jstypes.h | 12 ++++++++++++
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/js/src/configure.in b/js/src/configure.in
index 0bf9b75..daf53d2 100644
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -3134,15 +3134,6 @@ else
[int long 'long long' short])
fi

-MOZ_SIZE_OF_TYPE(JS_BYTES_PER_WORD, void*, 4 8)
-if test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "4"; then
- AC_DEFINE(JS_BITS_PER_WORD_LOG2, 5)
-elif test "$moz_cv_size_of_JS_BYTES_PER_WORD" -eq "8"; then
- AC_DEFINE(JS_BITS_PER_WORD_LOG2, 6)
-else
- AC_MSG_ERROR([Unexpected JS_BYTES_PER_WORD])
-fi
-
MOZ_ALIGN_OF_TYPE(JS_ALIGN_OF_POINTER, void*, 2 4 8 16)
MOZ_SIZE_OF_TYPE(JS_BYTES_PER_DOUBLE, double, 6 8 10 12 14)

diff --git a/js/src/js-config.h.in b/js/src/js-config.h.in
index e3a5f74..f30d5c3 100644
--- a/js/src/js-config.h.in
+++ b/js/src/js-config.h.in
@@ -81,7 +81,6 @@
#undef JS_INT32_TYPE
#undef JS_INT64_TYPE
#undef JS_INTPTR_TYPE
-#undef JS_BYTES_PER_WORD

/* Some mozilla code uses JS-friend APIs that depend on JS_TRACER and
JS_METHODJIT being correct. */
diff --git a/js/src/jstypes.h b/js/src/jstypes.h
index c2103d8..84d402e 100644
--- a/js/src/jstypes.h
+++ b/js/src/jstypes.h
@@ -56,6 +56,18 @@

#include <stddef.h>
#include "js-config.h"
+#ifndef JS_BYTES_PER_WORD
+#define JS_BYTES_PER_WORD __SIZEOF_POINTER__
+#endif
+#ifndef JS_BITS_PER_WORD_LOG2
+#if JS_BYTES_PER_WORD == 8
+#define JS_BITS_PER_WORD_LOG2 6
+#elif JS_BYTES_PER_WORD == 4
+#define JS_BITS_PER_WORD_LOG2 5
+#else
+#error Unhandled JS_BYTES_PER_WORD
+#endif
+#endif

/***********************************************************************
** MACROS: JS_EXTERN_API
--
1.8.3.1

@@ -0,0 +1,13 @@
--- js-1.8.5/js/src/configure.in 2011-03-31 22:08:36.000000000 +0300
+++ js-1.8.5/js/src/configure.in~ 2012-11-10 17:59:02.222497367 +0200
@@ -5615,8 +5615,8 @@ esac

if test -z "$SKIP_LIBRARY_CHECKS" -a -z "$NO_EDITLINE"; then
if test -n "$JS_WANT_READLINE"; then
- AC_CHECK_LIB(readline, readline,
- EDITLINE_LIBS="-lreadline",
+ AC_CHECK_LIB(edit, readline,
+ EDITLINE_LIBS="$(pkg-config --libs libedit)",
AC_MSG_ERROR([No system readline library found.]))
else
dnl By default, we use editline
@@ -0,0 +1,99 @@
diff -up js-1.8.5/js/src/jsval.h.tag js-1.8.5/js/src/jsval.h
--- js-1.8.5/js/src/jsval.h.tag 2017-03-10 16:27:06.000000000 +0100
+++ js-1.8.5/js/src/jsval.h 2017-03-10 16:30:39.000000000 +0100
@@ -66,7 +66,7 @@ JS_BEGIN_EXTERN_C
#endif

#if JS_BITS_PER_WORD == 64
-# define JSVAL_TAG_SHIFT 47
+# define JSVAL_TAG_SHIFT 48
#endif

/*
@@ -135,7 +135,8 @@ JS_STATIC_ASSERT(sizeof(JSValueTag) == 4
/* Remember to propagate changes to the C defines below. */
JS_ENUM_HEADER(JSValueTag, uint32)
{
- JSVAL_TAG_MAX_DOUBLE = 0x1FFF0,
+ JSVAL_TAG_DUMMY = 0xFFFFFFFF, /* Make sure the enums cannot fit 16-bits. */
+ JSVAL_TAG_MAX_DOUBLE = 0xFFF8,
JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32,
JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED,
JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING,
@@ -196,7 +197,7 @@ typedef uint32 JSValueTag;
#elif JS_BITS_PER_WORD == 64

typedef uint32 JSValueTag;
-#define JSVAL_TAG_MAX_DOUBLE ((uint32)(0x1FFF0))
+#define JSVAL_TAG_MAX_DOUBLE ((uint32)(0xFFF8))
#define JSVAL_TAG_INT32 (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32)
#define JSVAL_TAG_UNDEFINED (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED)
#define JSVAL_TAG_STRING (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING)
@@ -236,8 +237,8 @@ typedef uint64 JSValueShiftedTag;

#elif JS_BITS_PER_WORD == 64

-#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL
-#define JSVAL_TAG_MASK 0xFFFF800000000000LL
+#define JSVAL_PAYLOAD_MASK 0x0000FFFFFFFFFFFFLL
+#define JSVAL_TAG_MASK 0xFFFF000000000000LL
#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type)))
#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT)

@@ -297,8 +298,8 @@ typedef union jsval_layout
#if (!defined(_WIN64) && defined(__cplusplus))
/* MSVC does not pack these correctly :-( */
struct {
- uint64 payload47 : 47;
- JSValueTag tag : 17;
+ uint64 payload48 : 48;
+ JSValueTag tag : 16;
} debugView;
#endif
struct {
@@ -339,8 +340,8 @@ typedef union jsval_layout
{
uint64 asBits;
struct {
- JSValueTag tag : 17;
- uint64 payload47 : 47;
+ JSValueTag tag : 16;
+ uint64 payload48 : 48;
} debugView;
struct {
uint32 padding;
diff -up js-1.8.5/js/src/jsvalue.h.tag js-1.8.5/js/src/jsvalue.h
--- js-1.8.5/js/src/jsvalue.h.tag 2017-03-10 16:27:06.000000000 +0100
+++ js-1.8.5/js/src/jsvalue.h 2017-03-10 16:27:06.000000000 +0100
@@ -255,7 +255,7 @@ JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, j
{
uint64 lbits = lhs.asBits, rbits = rhs.asBits;
return (lbits <= JSVAL_TAG_MAX_DOUBLE && rbits <= JSVAL_TAG_MAX_DOUBLE) ||
- (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0);
+ (((lbits ^ rbits) & 0xFFFF000000000000LL) == 0);
}

static JS_ALWAYS_INLINE jsval_layout
@@ -277,7 +277,7 @@ JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layou
static JS_ALWAYS_INLINE JSValueType
JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l)
{
- uint64 type = (l.asBits >> JSVAL_TAG_SHIFT) & 0xF;
+ uint64 type = (l.asBits >> JSVAL_TAG_SHIFT) & 0x7;
JS_ASSERT(type > JSVAL_TYPE_DOUBLE);
return (JSValueType)type;
}
diff -up js-1.8.5/js/src/methodjit/MethodJIT.cpp.tag js-1.8.5/js/src/methodjit/MethodJIT.cpp
--- js-1.8.5/js/src/methodjit/MethodJIT.cpp.tag 2011-03-31 21:08:36.000000000 +0200
+++ js-1.8.5/js/src/methodjit/MethodJIT.cpp 2017-03-10 16:27:06.000000000 +0100
@@ -186,8 +186,8 @@ JS_STATIC_ASSERT(sizeof(VMFrame) % 16 ==
JS_STATIC_ASSERT(offsetof(VMFrame, savedRBX) == 0x58);
JS_STATIC_ASSERT(offsetof(VMFrame, regs.fp) == 0x38);

-JS_STATIC_ASSERT(JSVAL_TAG_MASK == 0xFFFF800000000000LL);
-JS_STATIC_ASSERT(JSVAL_PAYLOAD_MASK == 0x00007FFFFFFFFFFFLL);
+JS_STATIC_ASSERT(JSVAL_TAG_MASK == 0xFFFF000000000000LL);
+JS_STATIC_ASSERT(JSVAL_PAYLOAD_MASK == 0x0000FFFFFFFFFFFFLL);

asm volatile (
".text\n"
@@ -0,0 +1,37 @@
diff -Naur js-1.8.5.orig/js/src/assembler/wtf/Platform.h js-1.8.5/js/src/assembler/wtf/Platform.h
--- js-1.8.5.orig/js/src/assembler/wtf/Platform.h
+++ js-1.8.5/js/src/assembler/wtf/Platform.h
@@ -129,16 +129,22 @@
|| defined(__POWERPC__) \
|| defined(_M_PPC) \
|| defined(__PPC)
+#if !defined(__ppc64__) && !defined(__PPC64__)
#define WTF_CPU_PPC 1
+#endif
+#if !defined(__LITTLE_ENDIAN__)
#define WTF_CPU_BIG_ENDIAN 1
#endif
+#endif

/* CPU(PPC64) - PowerPC 64-bit */
#if defined(__ppc64__) \
|| defined(__PPC64__)
#define WTF_CPU_PPC64 1
+#if !defined(__LITTLE_ENDIAN__)
#define WTF_CPU_BIG_ENDIAN 1
#endif
+#endif

/* CPU(SH4) - SuperH SH-4 */
#if defined(__SH4__)
diff -Naur js-1.8.5.orig/js/src/configure.in js-1.8.5/js/src/configure.in
--- js-1.8.5.orig/js/src/configure.in
+++ js-1.8.5/js/src/configure.in
@@ -1498,7 +1498,7 @@
CPU_ARCH=x86
;;

-powerpc64 | ppc64)
+powerpc64 | ppc64 | powerpc64le | ppc64le)
CPU_ARCH=ppc64
;;
@@ -14,3 +14,7 @@ M68k-alignment-fixes.patch
disable-nanojit-on-x32.patch
disable-yarrjit-on-x32.patch
fix-cas-on-x32.patch
0001-Make-js-config.h-multiarch-compatible.patch
js185-libedit.patch
mozjs1.8.5-tag.patch
ppc64le.patch
@@ -1,22 +1,45 @@
diff -up js-1.8.5/js/src/jsval.h.pad-the-structs-and-asserts js-1.8.5/js/src/jsval.h
--- js-1.8.5/js/src/jsval.h.pad-the-structs-and-asserts 2011-11-28 12:46:32.811556132 -0600
+++ js-1.8.5/js/src/jsval.h 2011-11-28 12:46:43.493448233 -0600
@@ -343,11 +343,11 @@ typedef union jsval_layout
https://bugzilla.mozilla.org/show_bug.cgi?id=627664
https://bugzilla.mozilla.org/show_bug.cgi?id=674522

--- a/js/src/jsval.h
+++ b/js/src/jsval.h
@@ -306,11 +306,11 @@ typedef union jsval_layout
int32 i32;
uint32 u32;
JSWhyMagic why;
- jsuword word;
} payload;
} s;
double asDouble;
void *asPtr;
+ jsuword asWord;
} jsval_layout;
# endif /* JS_BITS_PER_WORD */
#else /* defined(IS_LITTLE_ENDIAN) */
@@ -343,6 +343,7 @@ typedef union jsval_layout
uint64 payload47 : 47;
} debugView;
struct {
+ uint32 padding;
union {
int32 i32;
uint32 u32;
JSWhyMagic why;
- jsuword word;
} payload;
@@ -351,10 +352,13 @@ typedef union jsval_layout
} s;
double asDouble;
diff -up js-1.8.5/js/src/jsvalue.h.pad-the-structs-and-asserts js-1.8.5/js/src/jsvalue.h
--- js-1.8.5/js/src/jsvalue.h.pad-the-structs-and-asserts 2011-11-28 12:46:37.246509255 -0600
+++ js-1.8.5/js/src/jsvalue.h 2011-11-28 12:46:43.495448203 -0600
void *asPtr;
+ jsuword asWord;
} jsval_layout;
# endif /* JS_BITS_PER_WORD */
#endif /* defined(IS_LITTLE_ENDIAN) */

+JS_STATIC_ASSERT(sizeof(jsval_layout) == 8);
+
#if JS_BITS_PER_WORD == 32

/*
--- a/js/src/jsvalue.h
+++ b/js/src/jsvalue.h
@@ -291,7 +291,6 @@ JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(jsval_
}

@@ -32,7 +55,7 @@ diff -up js-1.8.5/js/src/jsvalue.h.pad-the-structs-and-asserts js-1.8.5/js/src/j
+#if JS_BITS_PER_WORD == 32
return &data.s.payload.word;
+#elif JS_BITS_PER_WORD == 64
+ return &data.asBits;
+ return &data.asWord;
+#endif
}

@@ -0,0 +1,29 @@
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Mon, 21 Mar 2011 18:31:12 +0100
Subject: Bug 589744 - Fallback to perf measurement stub when perf_event_open
syscall isn't supported. r=ted

---
js/src/configure.in | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)

--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -3477,7 +3477,16 @@ case $target in
esac

dnl Performance measurement headers.
-AC_CHECK_HEADER(linux/perf_event.h, HAVE_LINUX_PERF_EVENT_H=1)
+AC_CHECK_HEADER(linux/perf_event.h,
+ [AC_CACHE_CHECK(for perf_event_open system call,ac_cv_perf_event_open,
+ [AC_TRY_COMPILE([#include <sys/syscall.h>],[return sizeof(__NR_perf_event_open);],
+ ac_cv_perf_event_open=yes,
+ ac_cv_perf_event_open=no)])])
+if test "$ac_cv_perf_event_open" = "yes"; then
+ HAVE_LINUX_PERF_EVENT_H=1
+else
+ HAVE_LINUX_PERF_EVENT_H=
+fi
AC_SUBST(HAVE_LINUX_PERF_EVENT_H)

dnl Checks for libraries.

0 comments on commit 1a0b467

Please sign in to comment.