diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..84b8df2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +SOURCES/mozjs-24.2.0.tar.bz2 diff --git a/.mozjs24.metadata b/.mozjs24.metadata new file mode 100644 index 0000000..87d795c --- /dev/null +++ b/.mozjs24.metadata @@ -0,0 +1 @@ +ce779081cc11bd0c871c6f303fc4a0091cf4fe66 SOURCES/mozjs-24.2.0.tar.bz2 diff --git a/SOURCES/js17-build-fixes.patch b/SOURCES/js17-build-fixes.patch new file mode 100644 index 0000000..4ef5123 --- /dev/null +++ b/SOURCES/js17-build-fixes.patch @@ -0,0 +1,38 @@ +From 0e27b45a3409e0a5c23e63af9e86048e1e7661da Mon Sep 17 00:00:00 2001 +From: Colin Walters +Date: Wed, 18 Jan 2012 22:25:47 -0500 +Subject: [PATCH] build: Add toplevel trampoline configure/Makefile + +These just invoke the ones in js/src. +--- + Makefile | 5 +++++ + configure | 5 +++++ + 2 files changed, 10 insertions(+), 0 deletions(-) + create mode 100644 Makefile + create mode 100755 configure + +diff --git a/Makefile b/Makefile +new file mode 100644 +index 0000000..98de844 +--- /dev/null ++++ b/Makefile +@@ -0,0 +1,5 @@ ++all: ++ cd js/src && $(MAKE) ++ ++install: ++ cd js/src && $(MAKE) install DESTDIR=$(DESTDIR) +diff --git a/configure b/configure +new file mode 100755 +index 0000000..93ef339 +--- /dev/null ++++ b/configure +@@ -0,0 +1,5 @@ ++#!/bin/sh ++# http://people.gnome.org/~walters/docs/build-api.txt ++echo \#buildapi-variable-no-builddir >/dev/null ++cd js/src ++exec ./configure "$@" +-- +1.7.1 + diff --git a/SOURCES/mozjs24-0001-Add-AArch64-support.patch b/SOURCES/mozjs24-0001-Add-AArch64-support.patch new file mode 100644 index 0000000..3895fff --- /dev/null +++ b/SOURCES/mozjs24-0001-Add-AArch64-support.patch @@ -0,0 +1,51 @@ +--- mozjs-24.2.0/js/src/assembler/jit/ExecutableAllocator.h.orig 2013-10-29 20:40:26.000000000 +0000 ++++ mozjs-24.2.0/js/src/assembler/jit/ExecutableAllocator.h 2014-01-22 16:52:53.603726328 +0000 +@@ -391,6 +391,12 @@ + { + reprotectRegion(start, size, Executable); + } ++#elif WTF_CPU_AARCH64 && WTF_PLATFORM_LINUX ++ static void cacheFlush(void* code, size_t size) ++ { ++ intptr_t end = reinterpret_cast(code) + size; ++ __builtin___clear_cache(reinterpret_cast(code), reinterpret_cast(end)); ++ } + #else + static void makeWritable(void*, size_t) {} + static void makeExecutable(void*, size_t) {} +--- mozjs-24.2.0/js/src/assembler/wtf/Platform.h.orig 2013-10-29 20:40:26.000000000 +0000 ++++ mozjs-24.2.0/js/src/assembler/wtf/Platform.h 2014-01-22 16:52:53.604726300 +0000 +@@ -326,6 +326,10 @@ + #define WTF_THUMB_ARCH_VERSION 0 + #endif + ++/* CPU(AArch64) - 64-bit ARM */ ++#if defined(__aarch64__) ++#define WTF_CPU_AARCH64 1 ++#endif + + /* WTF_CPU_ARMV5_OR_LOWER - ARM instruction set v5 or earlier */ + /* On ARMv5 and below the natural alignment is required. +--- mozjs-24.2.0/js/src/configure.in.orig 2013-12-11 22:22:50.000000000 +0000 ++++ mozjs-24.2.0/js/src/configure.in 2014-01-22 16:52:53.604726300 +0000 +@@ -1018,6 +1018,10 @@ + CPU_ARCH=arm + ;; + ++aarch64) ++ CPU_ARCH=aarch64 ++ ;; ++ + mips|mipsel) + CPU_ARCH="mips" + ;; +--- mozjs-24.2.0/mfbt/double-conversion/utils.h.orig 2014-01-22 16:52:42.596045903 +0000 ++++ mozjs-24.2.0/mfbt/double-conversion/utils.h 2014-01-22 16:52:53.605726272 +0000 +@@ -58,6 +58,7 @@ + defined(__mips__) || defined(__powerpc__) || \ + defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ + defined(__SH4__) || defined(__alpha__) || \ ++ defined(__aarch64__) || \ + defined(_MIPS_ARCH_MIPS32R2) + #define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 + #elif defined(_M_IX86) || defined(__i386__) || defined(__i386) diff --git a/SOURCES/mozjs24-48-bit-VA-fix.patch b/SOURCES/mozjs24-48-bit-VA-fix.patch new file mode 100644 index 0000000..3da8ddd --- /dev/null +++ b/SOURCES/mozjs24-48-bit-VA-fix.patch @@ -0,0 +1,57 @@ +From c3ef56fa3239d9133be922059300a6fd2e7c1435 Mon Sep 17 00:00:00 2001 +From: Zheng Xu +Date: Wed, 17 Aug 2016 11:59:15 +0800 +Subject: [PATCH] Bug 1143022 - Manually mmap on arm64 to ensure high 17 bits are clear. r=ehoogeveen + +There might be 48-bit VA on arm64 depending on kernel configuration. +Manually mmap heap memory to align with the assumption made by JS engine. + +Change-Id: Ic5d2b2fe4b758b3c87cc0688348af7e71a991146 +--- + +diff --git a/js/src/gc/Memory.cpp b/js/src/gc/Memory.cpp +index 153ccb4..b2d1311 100644 +--- a/js/src/gc/Memory.cpp ++++ b/js/src/gc/Memory.cpp +@@ -339,6 +339,41 @@ + return MAP_FAILED; + } + return region; ++#elif defined(__aarch64__) ++ /* ++ * There might be similar virtual address issue on arm64 which depends on ++ * hardware and kernel configurations. But the work around is slightly ++ * different due to the different mmap behavior. ++ * ++ * TODO: Merge with the above code block if this implementation works for ++ * ia64 and sparc64. ++ */ ++ const uintptr_t start = (uintptr_t)(0x0000070000000000UL); ++ const uintptr_t end = (uintptr_t)(0x0000800000000000UL); ++ const uintptr_t step = ChunkSize; ++ /* ++ * Optimization options if there are too many retries in practice: ++ * 1. Examine /proc/self/maps to find an available address. This file is ++ * not always available, however. In addition, even if we examine ++ * /proc/self/maps, we may still need to retry several times due to ++ * racing with other threads. ++ * 2. Use a global/static variable with lock to track the addresses we have ++ * allocated or tried. ++ */ ++ uintptr_t hint; ++ void* region = MAP_FAILED; ++ for (hint = start; region == MAP_FAILED && hint + length <= end; hint += step) { ++ region = mmap((void*)hint, length, prot, flags, fd, offset); ++ if (region != MAP_FAILED) { ++ if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) { ++ if (munmap(region, length)) { ++ MOZ_ASSERT(errno == ENOMEM); ++ } ++ region = MAP_FAILED; ++ } ++ } ++ } ++ return region == MAP_FAILED ? nullptr : region; + #else + return mmap(NULL, length, prot, flags, fd, offset); + #endif diff --git a/SPECS/mozjs24.spec b/SPECS/mozjs24.spec new file mode 100644 index 0000000..c87f7d6 --- /dev/null +++ b/SPECS/mozjs24.spec @@ -0,0 +1,121 @@ +Summary: JavaScript interpreter and libraries +Name: mozjs24 +Version: 24.2.0 +Release: 7%{?dist} +License: MPLv2.0 +Group: Development/Languages +URL: http://www.mozilla.org/js/ +Source0: http://ftp.mozilla.org/pub/mozilla.org/js/mozjs-%{version}.tar.bz2 +BuildRequires: pkgconfig(nspr) +BuildRequires: readline-devel +BuildRequires: /usr/bin/zip +BuildRequires: /usr/bin/python + +Patch0: js17-build-fixes.patch +Patch1: mozjs24-0001-Add-AArch64-support.patch +Patch2: mozjs24-48-bit-VA-fix.patch + +%description +JavaScript is the Netscape-developed object scripting language used in millions +of web pages and server applications worldwide. Netscape's JavaScript is a +super set of the ECMA-262 Edition 3 (ECMAScript) standard scripting language, +with only mild differences from the published standard. + +%package devel +Summary: Header files, libraries and development documentation for %{name} +Group: Development/Libraries +Requires: %{name}%{?_isa} = %{version}-%{release} + +%description devel +This package contains the header files, static libraries and development +documentation for %{name}. If you like to develop programs using %{name}, +you will need to install %{name}-devel. + +%prep +%setup -q -n mozjs-%{version} +# Delete bundled sources +rm js/src/editline -rf +rm js/src/ctypes/libffi -rf +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +chmod a+x configure + +%build +%configure \ + --disable-static \ + --with-system-nspr \ + --enable-threadsafe \ + --enable-readline \ + --enable-xterm-updates +make %{?_smp_mflags} + +%install +make install DESTDIR=%{buildroot} + +# For some reason the headers and pkg-config file are executable +find %{buildroot}%{_includedir} -type f -exec chmod a-x {} \; +chmod a-x %{buildroot}%{_libdir}/pkgconfig/*.pc + +# Fix multilib devel conflicts... +function install_file() { +genheader=$* +mv ${genheader}.h ${genheader}%{__isa_bits}.h +cat > ${genheader}.h << EOF +/* This file exists to fix multilib conflicts */ +#include +#if __WORDSIZE == 64 +#include "${genheader}64.h" +#else +#include "${genheader}32.h" +#endif +EOF +} + +pushd $RPM_BUILD_ROOT/%{_includedir}/mozjs-24 +install_file "js-config" +popd + +# Upstream does not honor --disable-static yet +rm -f %{buildroot}%{_libdir}/*.a +# This is also statically linked; once that is fixed that we could +# consider shipping it. +rm -f %{buildroot}%{_bindir}/js24 + +# However, delete js-config since everything should use +# the pkg-config file. +rm -f %{buildroot}%{_bindir}/js24-config + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + +%files +%doc LICENSE README +%{_libdir}/*.so + +%files devel +%{_libdir}/pkgconfig/*.pc +%{_includedir}/mozjs-24 + +%changelog +* Tue Mar 28 2017 Yaakov Selkowitz - 24.2.0-7 +- Fix crash with 48-bit VA on aarch64 (#1340183) + +* Wed May 27 2015 Martin Stransky 24.2.0-6 +- Added generic 64/32 bit check + +* Thu May 21 2015 Martin Stransky 24.2.0-5 +- Rebuild + +* Thu May 21 2015 Martin Stransky 24.2.0-4 +- Fixed multilib issue + +* Wed Jan 22 2014 Peter Robinson 24.2.0-3 +- Add patch to fix FTBFS on aarch64 + +* Fri Jan 10 2014 Debarshi Ray 24.2.0-2 +- Fix a spelling mistake + +* Thu Jan 09 2014 Debarshi Ray 24.2.0-1 +- Initial spec