summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2021-05-07 01:56:04 +0100
committerV3n3RiX <venerix@redcorelinux.org>2021-05-07 01:56:04 +0100
commit854735ef34c730eec54571f1d694a68c10e21c81 (patch)
treec2b0e2fef394452b1e1fb8a371dfbb948b2fca6c
parent533feecd029facba89f4a4a6c754ccfd5baec747 (diff)
dev-lang/spidermonkey : import from gentoo, compile with clang-12
-rw-r--r--dev-lang/spidermonkey/Manifest3
-rw-r--r--dev-lang/spidermonkey/files/moz38-dont-hardcode-libc-soname.patch15
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-1.8.5-LTO.patch58
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-52.0-fix-alpha-bitness.patch32
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-52.0-gcc9-overflow.patch24
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-fix-virtual-address-length.patch59
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-support.patch44
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-perl-defined-array-check.patch11
-rw-r--r--dev-lang/spidermonkey/spidermonkey-78.10.0-r10.ebuild446
9 files changed, 692 insertions, 0 deletions
diff --git a/dev-lang/spidermonkey/Manifest b/dev-lang/spidermonkey/Manifest
new file mode 100644
index 00000000..8507c456
--- /dev/null
+++ b/dev-lang/spidermonkey/Manifest
@@ -0,0 +1,3 @@
+DIST firefox-78.10.0esr.source.tar.xz 334642452 BLAKE2B a57e39e5f8d5bab08359957017bb44369598b49987b561176bcbb88b0bc10cd05214fd084faed872f4006e90e1b84a2f9b6f46049da763ef554d235c00d07519 SHA512 5e2cf137dc781855542c29df6152fa74ba749801640ade3cf01487ce993786b87a4f603d25c0af9323e67c7e15c75655523428c1c1426527b8623c7ded9f5946
+DIST firefox-78esr-patches-12.tar.xz 67840 BLAKE2B d85abdbb54a252852badac50866cf5b5009c050ec4aa80ae2454eef2719e80f3442f5a74ec58d3c36531539042830427cd85507b708c1d5b36ea44dd0cef60b7 SHA512 4445c0880fc234c3838394483ce986e4e222260a99427069ba9c55b56fcd49a485ec916ee6aa2629f922390e92bfcd78028e30cc2e62fad9bc080ae45b26ba2e
+DIST spidermonkey-78-patches-03.tar.xz 3732 BLAKE2B 5dc47527581c010994a102e6458119c762ec3836f57e403cbaac88c457f5f119bd75ae1a067307b20d229536f75db4b2b797408874d28156667ac63b61de8501 SHA512 f0921562dcd0ea519bf3f5ef2da43f87565e92493781d56e6e0b73d4124f41e7aadd34d8285bbb181f4286160dde0c9684920e98058f0683143a2687eb93cc1a
diff --git a/dev-lang/spidermonkey/files/moz38-dont-hardcode-libc-soname.patch b/dev-lang/spidermonkey/files/moz38-dont-hardcode-libc-soname.patch
new file mode 100644
index 00000000..708c7496
--- /dev/null
+++ b/dev-lang/spidermonkey/files/moz38-dont-hardcode-libc-soname.patch
@@ -0,0 +1,15 @@
+--- a/testing/mozbase/mozinfo/mozinfo/mozinfo.py 2018-01-12 12:21:16.764318254 -0500
++++ b/testing/mozbase/mozinfo/mozinfo/mozinfo.py 2018-01-12 12:22:23.392069398 -0500
+@@ -93,10 +93,11 @@
+
+ if info['os'] == 'linux':
+ import ctypes
++ import ctypes.util
+ import errno
+ PR_SET_SECCOMP = 22
+ SECCOMP_MODE_FILTER = 2
+- ctypes.CDLL("libc.so.6", use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
++ ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True).prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, 0)
+ info['has_sandbox'] = ctypes.get_errno() == errno.EFAULT
+ else:
+ info['has_sandbox'] = True
diff --git a/dev-lang/spidermonkey/files/spidermonkey-1.8.5-LTO.patch b/dev-lang/spidermonkey/files/spidermonkey-1.8.5-LTO.patch
new file mode 100644
index 00000000..7c36b552
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-1.8.5-LTO.patch
@@ -0,0 +1,58 @@
+From 6ff7ad09daf98e5b804cf73c066c382a76e74e8c Mon Sep 17 00:00:00 2001
+From: Alexander Miller <alex.miller@gmx.de>
+Date: Wed, 12 Jun 2019 00:29:23 -0500
+Subject: [PATCH] Fix breakage with lto builds
+
+<artificial>:(.text+0x7a): undefined reference to `PopActiveVMFrame'
+collect2: error: ld returned 1 exit status
+
+Signed-off-by: Alexander Miller <alex.miller@gmx.de>
+---
+ js/src/methodjit/InvokeHelpers.cpp | 2 +-
+ js/src/methodjit/MethodJIT.cpp | 6 +++---
+ 2 files changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/js/src/methodjit/InvokeHelpers.cpp b/js/src/methodjit/InvokeHelpers.cpp
+index d017c2a..abde396 100644
+--- a/js/src/methodjit/InvokeHelpers.cpp
++++ b/js/src/methodjit/InvokeHelpers.cpp
+@@ -500,7 +500,7 @@ stubs::PutActivationObjects(VMFrame &f)
+ js::PutActivationObjects(f.cx, f.fp());
+ }
+
+-extern "C" void *
++extern "C" void * __attribute__((used))
+ js_InternalThrow(VMFrame &f)
+ {
+ JSContext *cx = f.cx;
+diff --git a/js/src/methodjit/MethodJIT.cpp b/js/src/methodjit/MethodJIT.cpp
+index 4feefbc..66099e6 100644
+--- a/js/src/methodjit/MethodJIT.cpp
++++ b/js/src/methodjit/MethodJIT.cpp
+@@ -120,20 +120,20 @@ static uint32 StubCallsForOp[STUB_CALLS_FOR_OP_COUNT];
+
+ extern "C" void JaegerTrampolineReturn();
+
+-extern "C" void JS_FASTCALL
++extern "C" void JS_FASTCALL __attribute__((used))
+ PushActiveVMFrame(VMFrame &f)
+ {
+ f.entryfp->script()->compartment->jaegerCompartment->pushActiveFrame(&f);
+ f.regs.fp->setNativeReturnAddress(JS_FUNC_TO_DATA_PTR(void*, JaegerTrampolineReturn));
+ }
+
+-extern "C" void JS_FASTCALL
++extern "C" void JS_FASTCALL __attribute__((used))
+ PopActiveVMFrame(VMFrame &f)
+ {
+ f.entryfp->script()->compartment->jaegerCompartment->popActiveFrame();
+ }
+
+-extern "C" void JS_FASTCALL
++extern "C" void JS_FASTCALL __attribute__((used))
+ SetVMFrameRegs(VMFrame &f)
+ {
+ f.cx->setCurrentRegs(&f.regs);
+--
+2.22.0
+
diff --git a/dev-lang/spidermonkey/files/spidermonkey-52.0-fix-alpha-bitness.patch b/dev-lang/spidermonkey/files/spidermonkey-52.0-fix-alpha-bitness.patch
new file mode 100644
index 00000000..b0f87296
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-52.0-fix-alpha-bitness.patch
@@ -0,0 +1,32 @@
+
+# HG changeset patch
+# User John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
+# Date 1482966103 -3600
+# Node ID 1f4d99d8dff27bcc25eff21dc6a16dae63f48595
+# Parent ce9e9f0dc752896ac7ba00bb0610b3f731e948b0
+Bug 1326496 - mozbuild: Fix bitness from 32 to 64 bits on alpha. r=glandium
+
+
+diff --git a/python/mozbuild/mozbuild/configure/constants.py b/python/mozbuild/mozbuild/configure/constants.py
+--- a/python/mozbuild/mozbuild/configure/constants.py
++++ b/python/mozbuild/mozbuild/configure/constants.py
+@@ -35,17 +35,17 @@ Kernel = EnumString.subclass(
+ 'Linux',
+ 'NetBSD',
+ 'OpenBSD',
+ 'WINNT',
+ )
+
+ CPU_bitness = {
+ 'aarch64': 64,
+- 'Alpha': 32,
++ 'Alpha': 64,
+ 'arm': 32,
+ 'hppa': 32,
+ 'ia64': 64,
+ 'mips32': 32,
+ 'mips64': 64,
+ 'ppc': 32,
+ 'ppc64': 64,
+ 's390': 32,
+
diff --git a/dev-lang/spidermonkey/files/spidermonkey-52.0-gcc9-overflow.patch b/dev-lang/spidermonkey/files/spidermonkey-52.0-gcc9-overflow.patch
new file mode 100644
index 00000000..c7eb0f62
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-52.0-gcc9-overflow.patch
@@ -0,0 +1,24 @@
+From 311fc467219ab6ee9eed60759b58a8066c4bf36d Mon Sep 17 00:00:00 2001
+From:
+Date: Thu, 25 Jul 2019 10:00:33 -0500
+Subject: [PATCH] gcc-9 overflow fix
+
+---
+ js/src/jsapi-tests/testPrintf.cpp | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/js/src/jsapi-tests/testPrintf.cpp b/js/src/jsapi-tests/testPrintf.cpp
+index 51486856..03cc118d 100644
+--- a/js/src/jsapi-tests/testPrintf.cpp
++++ b/js/src/jsapi-tests/testPrintf.cpp
+@@ -55,7 +55,6 @@ BEGIN_TEST(testPrintf)
+ CHECK(print_one("27270", "%zu", (size_t) 27270));
+ CHECK(print_one("27270", "%" PRIuSIZE, (size_t) 27270));
+ CHECK(print_one("hello", "he%so", "ll"));
+- CHECK(print_one("(null)", "%s", zero()));
+ CHECK(print_one("0", "%p", (char *) 0));
+ CHECK(print_one("h", "%c", 'h'));
+ CHECK(print_one("1.500000", "%f", 1.5f));
+--
+2.22.0
+
diff --git a/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-fix-virtual-address-length.patch b/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-fix-virtual-address-length.patch
new file mode 100644
index 00000000..8b2245f1
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-fix-virtual-address-length.patch
@@ -0,0 +1,59 @@
+From 8099213b51180254b322332ecd573239da4212c4 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 23 Jan 2020 22:57:53 +0000
+Subject: [PATCH] ProcessExecutableMemory.cpp: fix virtual address length on
+ ia64
+
+ia64's usable virtual address space is page dependent. For 16K
+pages with 3 levels of page tables de can address only 44 bits
+of virtual memory, not default 47.
+
+The change makes page size detection dynamic and adapts to
+addressable bits. On ia64 it is '4 * log2(page_size/8)'.
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ js/src/jit/ProcessExecutableMemory.cpp | 25 +++++++++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/js/src/jit/ProcessExecutableMemory.cpp b/js/src/jit/ProcessExecutableMemory.cpp
+index 9e55c262..8581c150 100644
+--- a/js/src/jit/ProcessExecutableMemory.cpp
++++ b/js/src/jit/ProcessExecutableMemory.cpp
+
+@@ -248,7 +248,32 @@ static void* ComputeRandomAllocationAddress() {
+ // x64 CPUs have a 48-bit address space and on some platforms the OS will
+ // give us access to 47 bits, so to be safe we right shift by 18 to leave
+ // 46 bits.
++# ifdef __ia64__
++ // On ia64 virtual address space looks like one of:
++ // virt_addr_64 = [ <63..61> | <unimplemented> | L3 | L2 | L1 | offset ]
++ // virt_addr_64 = [ <63..61> | <unimplemented> | L4 | L3 | L2 | L1 | offset ]
++ // where L{1..L4} are page tables. Each page table (except top-level L3 or L4)
++ // is itself a page-size entry and can store PageSize / 8 entries. Top-level
++ // entry is 1/8 of of L1/L2 (as 3 upper bits are part of <63..61> address part).
++ // Note: that makes addressable size directly depend on page size.
++ //
++ // We conservatively assume 3 levels of page tables here. This makes the
++ // following formula:
++ // L3 = log2(PAGE / 8 / 8) = log2(PAGE / 8) - 3
++ // L2 = log2(PAGE / 8)
++ // L1 = log2(PAGE / 8)
++ // offset = log2(PAGE) = log2(PAGE / 8) + 3
++ // thus
++ // L3 + L2 + L1 + offset = 4 * log2(PAGE / 8)
++ // For more details see http://www.ia64-linux.org/doc/IA64linuxkernel.PDF
++ // (slide 19: "user regions").
++ static uint64_t ia64_virt_bits = std::min<uint64_t>(
++ 4 * (mozilla::FloorLog2(gc::SystemPageSize() / 8)),
++ 46);
++ rand >>= (64 - ia64_virt_bits);
++# else
+ rand >>= 18;
++# endif
+ #else
+ // On 32-bit, right shift by 34 to leave 30 bits, range [0, 1GiB). Then add
+ // 512MiB to get range [512MiB, 1.5GiB), or [0x20000000, 0x60000000). This
+--
+2.25.0
+
diff --git a/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-support.patch b/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-support.patch
new file mode 100644
index 00000000..90c8a4c9
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-support.patch
@@ -0,0 +1,44 @@
+From 35d787c782a075c0a01e29605d254950fd1e81a6 Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Thu, 25 Jul 2019 10:17:39 -0500
+Subject: [PATCH] Add support for ia64 atomic-ops
+
+Signed-off-by: Jory Pratt <anarchy@gentoo.org>
+---
+ js/src/jit/AtomicOperations.h | 2 ++
+ js/src/jit/none/AtomicOperations-feeling-lucky.h | 6 ++++++
+ 2 files changed, 8 insertions(+)
+
+diff --git a/js/src/jit/AtomicOperations.h b/js/src/jit/AtomicOperations.h
+index 3501e65b..44c3f358 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(__ia64__)
++#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..a3f4497e 100644
+--- a/js/src/jit/none/AtomicOperations-feeling-lucky.h
++++ b/js/src/jit/none/AtomicOperations-feeling-lucky.h
+@@ -80,6 +80,12 @@
+ #define GNUC_COMPATIBLE
+ #endif
+
++#ifdef __ia64__
++#define HAS_64BIT_ATOMICS
++#define HAS_64BIT_LOCKFREE
++#define GNUC_COMPATIBLE
++#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.
+--
+2.22.0
+
diff --git a/dev-lang/spidermonkey/files/spidermonkey-perl-defined-array-check.patch b/dev-lang/spidermonkey/files/spidermonkey-perl-defined-array-check.patch
new file mode 100644
index 00000000..c3996ae8
--- /dev/null
+++ b/dev-lang/spidermonkey/files/spidermonkey-perl-defined-array-check.patch
@@ -0,0 +1,11 @@
+--- a/js/src/config/milestone.pl 2013-02-11 17:33:22.000000000 -0500
++++ b/js/src/config/milestone.pl 2015-07-15 10:44:31.676153600 -0400
+@@ -55,7 +55,7 @@
+ #
+ my $milestone = Moz::Milestone::getOfficialMilestone($MILESTONE_FILE);
+
+-if (defined(@TEMPLATE_FILE)) {
++if (@TEMPLATE_FILE) {
+ my $TFILE;
+
+ foreach $TFILE (@TEMPLATE_FILE) {
diff --git a/dev-lang/spidermonkey/spidermonkey-78.10.0-r10.ebuild b/dev-lang/spidermonkey/spidermonkey-78.10.0-r10.ebuild
new file mode 100644
index 00000000..e5bacf41
--- /dev/null
+++ b/dev-lang/spidermonkey/spidermonkey-78.10.0-r10.ebuild
@@ -0,0 +1,446 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI="7"
+
+# Patch version
+FIREFOX_PATCHSET="firefox-78esr-patches-12.tar.xz"
+SPIDERMONKEY_PATCHSET="spidermonkey-78-patches-03.tar.xz"
+
+LLVM_MAX_SLOT=12
+
+PYTHON_COMPAT=( python3_{7..9} )
+
+WANT_AUTOCONF="2.1"
+
+inherit autotools check-reqs flag-o-matic llvm multiprocessing python-any-r1 toolchain-funcs
+
+MY_PN="mozjs"
+MY_PV="${PV/_pre*}" # Handle Gentoo pre-releases
+
+MY_MAJOR=$(ver_cut 1)
+
+MOZ_ESR=yes
+
+MOZ_PV=${PV}
+MOZ_PV_SUFFIX=
+if [[ ${PV} =~ (_(alpha|beta|rc).*)$ ]] ; then
+ MOZ_PV_SUFFIX=${BASH_REMATCH[1]}
+
+ # Convert the ebuild version to the upstream Mozilla version
+ MOZ_PV="${MOZ_PV/_alpha/a}" # Handle alpha for SRC_URI
+ MOZ_PV="${MOZ_PV/_beta/b}" # Handle beta for SRC_URI
+ MOZ_PV="${MOZ_PV%%_rc*}" # Handle rc for SRC_URI
+fi
+
+if [[ -n ${MOZ_ESR} ]] ; then
+ # ESR releases have slightly different version numbers
+ MOZ_PV="${MOZ_PV}esr"
+fi
+
+MOZ_PN="firefox"
+MOZ_P="${MOZ_PN}-${MOZ_PV}"
+MOZ_PV_DISTFILES="${MOZ_PV}${MOZ_PV_SUFFIX}"
+MOZ_P_DISTFILES="${MOZ_PN}-${MOZ_PV_DISTFILES}"
+
+MOZ_SRC_BASE_URI="https://archive.mozilla.org/pub/${MOZ_PN}/releases/${MOZ_PV}"
+
+if [[ ${PV} == *_rc* ]] ; then
+ MOZ_SRC_BASE_URI="https://archive.mozilla.org/pub/${MOZ_PN}/candidates/${MOZ_PV}-candidates/build${PV##*_rc}"
+fi
+
+PATCH_URIS=(
+ https://dev.gentoo.org/~{whissi,polynomial-c,axs}/mozilla/patchsets/${FIREFOX_PATCHSET}
+ https://dev.gentoo.org/~{whissi,polynomial-c,axs}/mozilla/patchsets/${SPIDERMONKEY_PATCHSET}
+)
+
+SRC_URI="${MOZ_SRC_BASE_URI}/source/${MOZ_P}.source.tar.xz -> ${MOZ_P_DISTFILES}.source.tar.xz
+ ${PATCH_URIS[@]}"
+
+DESCRIPTION="SpiderMonkey is Mozilla's JavaScript engine written in C and C++"
+HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey"
+
+KEYWORDS="amd64 arm arm64 ~mips ppc64 ~s390 x86"
+
+SLOT="78"
+LICENSE="MPL-2.0"
+IUSE="clang cpu_flags_arm_neon debug +jit lto test"
+
+RESTRICT="!test? ( test )"
+
+BDEPEND="${PYTHON_DEPS}
+ >=virtual/rust-1.41.0
+ virtual/pkgconfig
+ || (
+ (
+ sys-devel/llvm:12
+ clang? (
+ sys-devel/clang:12
+ lto? ( =sys-devel/lld-12* )
+ )
+ )
+ (
+ sys-devel/llvm:11
+ clang? (
+ sys-devel/clang:11
+ lto? ( =sys-devel/lld-11* )
+ )
+ )
+ (
+ sys-devel/llvm:10
+ clang? (
+ sys-devel/clang:10
+ lto? ( =sys-devel/lld-10* )
+ )
+ )
+ )
+ lto? (
+ !clang? ( sys-devel/binutils[gold] )
+ )"
+
+CDEPEND=">=dev-libs/icu-67.1:=
+ >=dev-libs/nspr-4.25
+ sys-libs/readline:0=
+ >=sys-libs/zlib-1.2.3"
+
+DEPEND="${CDEPEND}
+ test? (
+ $(python_gen_any_dep 'dev-python/six[${PYTHON_USEDEP}]')
+ )"
+
+RDEPEND="${CDEPEND}"
+
+S="${WORKDIR}/firefox-${MY_PV}/js/src"
+
+llvm_check_deps() {
+ if use clang ; then
+ if ! has_version -b "sys-devel/clang:${LLVM_SLOT}" ; then
+ ewarn "sys-devel/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
+ return 1
+ fi
+
+ if use lto ; then
+ if ! has_version -b "=sys-devel/lld-${LLVM_SLOT}*" ; then
+ ewarn "=sys-devel/lld-${LLVM_SLOT}* is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
+ return 1
+ fi
+ fi
+ fi
+
+ einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2
+}
+
+python_check_deps() {
+ if use test ; then
+ has_version "dev-python/six[${PYTHON_USEDEP}]"
+ fi
+}
+
+pkg_pretend() {
+ if use test ; then
+ CHECKREQS_DISK_BUILD="7600M"
+ else
+ CHECKREQS_DISK_BUILD="6400M"
+ fi
+
+ check-reqs_pkg_pretend
+}
+
+pkg_setup() {
+ if [[ ${MERGE_TYPE} != binary ]] ; then
+ if use test ; then
+ CHECKREQS_DISK_BUILD="7600M"
+ else
+ CHECKREQS_DISK_BUILD="6400M"
+ fi
+
+ check-reqs_pkg_setup
+
+ llvm_pkg_setup
+
+ if use clang && use lto ; then
+ local version_lld=$(ld.lld --version 2>/dev/null | awk '{ print $2 }')
+ [[ -n ${version_lld} ]] && version_lld=$(ver_cut 1 "${version_lld}")
+ [[ -z ${version_lld} ]] && die "Failed to read ld.lld version!"
+
+ # temp fix for https://bugs.gentoo.org/768543
+ # we can assume that rust 1.{49,50}.0 always uses llvm 11
+ local version_rust=$(rustc -Vv 2>/dev/null | grep -F -- 'release:' | awk '{ print $2 }')
+ [[ -n ${version_rust} ]] && version_rust=$(ver_cut 1-2 "${version_rust}")
+ [[ -z ${version_rust} ]] && die "Failed to read version from rustc!"
+
+ if ver_test "${version_rust}" -ge "1.49" && ver_test "${version_rust}" -le "1.50" ; then
+ local version_llvm_rust="11"
+ else
+ local version_llvm_rust=$(rustc -Vv 2>/dev/null | grep -F -- 'LLVM version:' | awk '{ print $3 }')
+ [[ -n ${version_llvm_rust} ]] && version_llvm_rust=$(ver_cut 1 "${version_llvm_rust}")
+ [[ -z ${version_llvm_rust} ]] && die "Failed to read used LLVM version from rustc!"
+ fi
+
+ if ver_test "${version_lld}" -ne "${version_llvm_rust}" ; then
+ eerror "Rust is using LLVM version ${version_llvm_rust} but ld.lld version belongs to LLVM version ${version_lld}."
+ eerror "You will be unable to link ${CATEGORY}/${PN}. To proceed you have the following options:"
+ eerror " - Manually switch rust version using 'eselect rust' to match used LLVM version"
+ eerror " - Switch to dev-lang/rust[system-llvm] which will guarantee matching version"
+ eerror " - Build ${CATEGORY}/${PN} without USE=lto"
+ die "LLVM version used by Rust (${version_llvm_rust}) does not match with ld.lld version (${version_lld})!"
+ fi
+ fi
+
+ python-any-r1_pkg_setup
+
+ # Build system is using /proc/self/oom_score_adj, bug #604394
+ addpredict /proc/self/oom_score_adj
+
+ if ! mountpoint -q /dev/shm ; then
+ # If /dev/shm is not available, configure is known to fail with
+ # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py
+ ewarn "/dev/shm is not mounted -- expect build failures!"
+ fi
+
+ # Ensure we use C locale when building, bug #746215
+ export LC_ALL=C
+ fi
+}
+
+src_prepare() {
+ pushd ../.. &>/dev/null || die
+
+ use lto && rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch
+
+ eapply "${WORKDIR}"/firefox-patches
+ eapply "${WORKDIR}"/spidermonkey-patches
+
+ default
+
+ # Make LTO respect MAKEOPTS
+ sed -i \
+ -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \
+ build/moz.configure/lto-pgo.configure \
+ || die "sed failed to set num_cores"
+
+ # sed-in toolchain prefix
+ sed -i \
+ -e "s/objdump/${CHOST}-objdump/" \
+ python/mozbuild/mozbuild/configure/check_debug_ranges.py \
+ || die "sed failed to set toolchain prefix"
+
+ einfo "Removing pre-built binaries ..."
+ find third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die
+
+ MOZJS_BUILDDIR="${WORKDIR}/build"
+ mkdir "${MOZJS_BUILDDIR}" || die
+
+ popd &>/dev/null || die
+ eautoconf
+}
+
+src_configure() {
+ # Show flags set at the beginning
+ einfo "Current CFLAGS: ${CFLAGS}"
+ einfo "Current CXXFLAGS: ${CXXFLAGS}"
+ einfo "Current LDFLAGS: ${LDFLAGS}"
+ einfo "Current RUSTFLAGS: ${RUSTFLAGS}"
+
+ local have_switched_compiler=
+ if use clang && ! tc-is-clang ; then
+ # Force clang
+ einfo "Enforcing the use of clang due to USE=clang ..."
+ have_switched_compiler=yes
+ AR=llvm-ar
+ CC=${CHOST}-clang
+ CXX=${CHOST}-clang++
+ NM=llvm-nm
+ RANLIB=llvm-ranlib
+ elif ! use clang && ! tc-is-gcc ; then
+ # Force gcc
+ have_switched_compiler=yes
+ einfo "Enforcing the use of gcc due to USE=-clang ..."
+ AR=gcc-ar
+ CC=${CHOST}-gcc
+ CXX=${CHOST}-g++
+ NM=gcc-nm
+ RANLIB=gcc-ranlib
+ fi
+
+ if [[ -n "${have_switched_compiler}" ]] ; then
+ # Because we switched active compiler we have to ensure
+ # that no unsupported flags are set
+ strip-unsupported-flags
+ fi
+
+ # Ensure we use correct toolchain
+ export HOST_CC="$(tc-getBUILD_CC)"
+ export HOST_CXX="$(tc-getBUILD_CXX)"
+ tc-export CC CXX LD AR NM OBJDUMP RANLIB PKG_CONFIG
+
+ cd "${MOZJS_BUILDDIR}" || die
+
+ # ../python/mach/mach/mixin/process.py fails to detect SHELL
+ export SHELL="${EPREFIX}/bin/bash"
+
+ local -a myeconfargs=(
+ --host="${CBUILD:-${CHOST}}"
+ --target="${CHOST}"
+ --disable-jemalloc
+ --disable-optimize
+ --disable-strip
+ --enable-readline
+ --enable-shared-js
+ --with-intl-api
+ --with-system-icu
+ --with-system-nspr
+ --with-system-zlib
+ --with-toolchain-prefix="${CHOST}-"
+ $(use_enable debug)
+ $(use_enable jit)
+ $(use_enable test tests)
+ )
+
+ if ! use x86 && [[ ${CHOST} != armv*h* ]] ; then
+ myeconfargs+=( --enable-rust-simd )
+ fi
+
+ # Modifications to better support ARM, bug 717344
+ if use cpu_flags_arm_neon ; then
+ myeconfargs+=( --with-fpu=neon )
+
+ if ! tc-is-clang ; then
+ # thumb options aren't supported when using clang, bug 666966
+ myeconfargs+=( --with-thumb=yes )
+ myeconfargs+=( --with-thumb-interwork=no )
+ fi
+ fi
+
+ # Tell build system that we want to use LTO
+ if use lto ; then
+ myeconfargs+=( --enable-lto )
+
+ if use clang ; then
+ myeconfargs+=( --enable-linker=lld )
+ else
+ myeconfargs+=( --enable-linker=gold )
+ fi
+ fi
+
+ # LTO flag was handled via configure
+ filter-flags '-flto*'
+
+ if tc-is-gcc ; then
+ if ver_test $(gcc-fullversion) -ge 10 ; then
+ einfo "Forcing -fno-tree-loop-vectorize to workaround GCC bug, see bug 758446 ..."
+ append-cxxflags -fno-tree-loop-vectorize
+ fi
+ fi
+
+ # Show flags we will use
+ einfo "Build CFLAGS: ${CFLAGS}"
+ einfo "Build CXXFLAGS: ${CXXFLAGS}"
+ einfo "Build LDFLAGS: ${LDFLAGS}"
+ einfo "Build RUSTFLAGS: ${RUSTFLAGS}"
+
+ # Forcing system-icu allows us to skip patching bundled ICU for PPC
+ # and other minor arches
+ ECONF_SOURCE="${S}" \
+ econf \
+ ${myeconfargs[@]} \
+ XARGS="${EPREFIX}/usr/bin/xargs"
+}
+
+src_compile() {
+ cd "${MOZJS_BUILDDIR}" || die
+ default
+}
+
+src_test() {
+ if "${MOZJS_BUILDDIR}/js/src/js" -e 'print("Hello world!")'; then
+ einfo "Smoke-test successful, continuing with full test suite"
+ else
+ die "Smoke-test failed: did interpreter initialization fail?"
+ fi
+
+ local -a KNOWN_TESTFAILURES
+ KNOWN_TESTFAILURES+=( non262/Date/reset-time-zone-cache-same-offset.js )
+ KNOWN_TESTFAILURES+=( non262/Date/time-zone-path.js )
+ KNOWN_TESTFAILURES+=( non262/Date/time-zones-historic.js )
+ KNOWN_TESTFAILURES+=( non262/Date/time-zones-imported.js )
+ KNOWN_TESTFAILURES+=( non262/Date/toString-localized.js )
+ KNOWN_TESTFAILURES+=( non262/Date/toString-localized-posix.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/Date/toLocaleString_timeZone.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/Date/toLocaleDateString_timeZone.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DateTimeFormat/format.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DateTimeFormat/format_timeZone.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DateTimeFormat/timeZone_backward_links.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DateTimeFormat/tz-environment-variable.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DisplayNames/language.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/DisplayNames/region.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/Locale/likely-subtags.js )
+ KNOWN_TESTFAILURES+=( non262/Intl/Locale/likely-subtags-generated.js )
+ KNOWN_TESTFAILURES+=( test262/intl402/Locale/prototype/minimize/removing-likely-subtags-first-adds-likely-subtags.js )
+
+ if use x86 ; then
+ KNOWN_TESTFAILURES+=( non262/Date/timeclip.js )
+ KNOWN_TESTFAILURES+=( test262/built-ins/Number/prototype/toPrecision/return-values.js )
+ KNOWN_TESTFAILURES+=( test262/language/types/number/S8.5_A2.1.js )
+ KNOWN_TESTFAILURES+=( test262/language/types/number/S8.5_A2.2.js )
+ fi
+
+ if [[ $(tc-endian) == "big" ]] ; then
+ KNOWN_TESTFAILURES+=( test262/built-ins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js )
+ fi
+
+ echo "" > "${T}"/known_failures.list || die
+
+ local KNOWN_TESTFAILURE
+ for KNOWN_TESTFAILURE in ${KNOWN_TESTFAILURES[@]} ; do
+ echo "${KNOWN_TESTFAILURE}" >> "${T}"/known_failures.list
+ done
+
+ PYTHONPATH="${S}/tests/lib" \
+ ${PYTHON} \
+ "${S}"/tests/jstests.py -d -s -t 1800 --wpt=disabled --no-progress \
+ --exclude-file="${T}"/known_failures.list \
+ "${MOZJS_BUILDDIR}"/js/src/js \
+ || die
+
+ if use jit ; then
+ KNOWN_TESTFAILURES=()
+
+ echo "" > "${T}"/known_failures.list || die
+
+ for KNOWN_TESTFAILURE in ${KNOWN_TESTFAILURES[@]} ; do
+ echo "${KNOWN_TESTFAILURE}" >> "${T}"/known_failures.list
+ done
+
+ PYTHONPATH="${S}/tests/lib" \
+ ${PYTHON} \
+ "${S}"/tests/jstests.py -d -s -t 1800 --wpt=disabled --no-progress \
+ --exclude-file="${T}"/known_failures.list \
+ "${MOZJS_BUILDDIR}"/js/src/js basic \
+ || die
+ fi
+}
+
+src_install() {
+ cd "${MOZJS_BUILDDIR}" || die
+ default
+
+ # fix soname links
+ pushd "${ED}"/usr/$(get_libdir) &>/dev/null || die
+ mv lib${MY_PN}-${MY_MAJOR}.so lib${MY_PN}-${MY_MAJOR}.so.0.0.0 || die
+ ln -s lib${MY_PN}-${MY_MAJOR}.so.0.0.0 lib${MY_PN}-${MY_MAJOR}.so.0 || die
+ ln -s lib${MY_PN}-${MY_MAJOR}.so.0 lib${MY_PN}-${MY_MAJOR}.so || die
+ popd &>/dev/null || die
+
+ # remove unneeded files
+ rm \
+ "${ED}"/usr/bin/js${MY_MAJOR}-config \
+ "${ED}"/usr/$(get_libdir)/libjs_static.ajs \
+ || die
+
+ # fix permissions
+ chmod -x \
+ "${ED}"/usr/$(get_libdir)/pkgconfig/*.pc \
+ "${ED}"/usr/include/mozjs-${MY_MAJOR}/js-config.h \
+ || die
+}