summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-04-21 13:50:14 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-04-21 13:50:14 +0200
commit40244e2b380a51c29d895828c134ca1090810581 (patch)
tree4b2ae38d344ec5eb2467a3289567c96ce9b6ca6f /dev-lang
parentnet-misc/openssh: security cleanup (diff)
downloadgentoo-40244e2b380a51c29d895828c134ca1090810581.tar.gz
gentoo-40244e2b380a51c29d895828c134ca1090810581.tar.bz2
gentoo-40244e2b380a51c29d895828c134ca1090810581.zip
dev-lang/spidermonkey: fix virtual address length on ia64
Closes: https://bugs.gentoo.org/703538 Package-Manager: Portage-2.3.99, Repoman-2.3.22 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
Diffstat (limited to 'dev-lang')
-rw-r--r--dev-lang/spidermonkey/files/spidermonkey-60.5.2-ia64-fix-virtual-address-length.patch59
-rw-r--r--dev-lang/spidermonkey/spidermonkey-60.5.2_p0-r4.ebuild155
2 files changed, 214 insertions, 0 deletions
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 000000000000..8b2245f1e353
--- /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/spidermonkey-60.5.2_p0-r4.ebuild b/dev-lang/spidermonkey/spidermonkey-60.5.2_p0-r4.ebuild
new file mode 100644
index 000000000000..997ed7605226
--- /dev/null
+++ b/dev-lang/spidermonkey/spidermonkey-60.5.2_p0-r4.ebuild
@@ -0,0 +1,155 @@
+# Copyright 1999-2020 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+WANT_AUTOCONF="2.1"
+inherit autotools check-reqs toolchain-funcs pax-utils mozcoreconf-v5
+
+MY_PN="mozjs"
+MY_P="${MY_PN}-${PV/_rc/.rc}"
+MY_P="${MY_P/_pre/pre}"
+MY_P="${MY_P%_p[0-9]*}"
+DESCRIPTION="Stand-alone JavaScript C++ library"
+HOMEPAGE="https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey"
+#SRC_URI="https://archive.mozilla.org/pub/spidermonkey/prereleases/60/pre3/${MY_P}.tar.bz2
+SRC_URI="https://dev.gentoo.org/~axs/distfiles/${MY_P}.tar.bz2
+ https://dev.gentoo.org/~anarchy/mozilla/patchsets/${PN}-60.0-patches-04.tar.xz"
+
+LICENSE="NPL-1.1"
+SLOT="60"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~s390 ~sparc ~x86"
+IUSE="debug +jit minimal +system-icu test"
+
+RESTRICT="!test? ( test ) ia64? ( test )"
+
+S="${WORKDIR}/${MY_P%.rc*}"
+
+BUILDDIR="${S}/jsobj"
+
+RDEPEND=">=dev-libs/nspr-4.13.1
+ virtual/libffi
+ sys-libs/readline:0=
+ >=sys-libs/zlib-1.2.3:=
+ system-icu? ( >=dev-libs/icu-59.1:= )"
+DEPEND="${RDEPEND}"
+
+pkg_pretend() {
+ CHECKREQS_DISK_BUILD="2G"
+
+ check-reqs_pkg_setup
+}
+pkg_setup() {
+ [[ ${MERGE_TYPE} == "binary" ]] || \
+ moz_pkgsetup
+ export SHELL="${EPREFIX}/bin/bash"
+}
+
+src_prepare() {
+ eapply "${WORKDIR}/${PN}"
+ eapply "${FILESDIR}/${PN}-60.5.2-ia64-support.patch"
+ eapply "${FILESDIR}/${PN}-60.5.2-ia64-fix-virtual-address-length.patch"
+
+ eapply_user
+
+ if [[ ${CHOST} == *-freebsd* ]]; then
+ # Don't try to be smart, this does not work in cross-compile anyway
+ ln -sfn "${BUILDDIR}/config/Linux_All.mk" "${S}/config/$(uname -s)$(uname -r).mk" || die
+ fi
+
+ cd "${S}/js/src" || die
+ eautoconf old-configure.in
+ eautoconf
+
+ # remove options that are not correct from js-config
+ sed '/lib-filenames/d' -i "${S}"/js/src/build/js-config.in || die "failed to remove invalid option from js-config"
+
+ # there is a default config.cache that messes everything up
+ rm -f "${S}/js/src"/config.cache || die
+
+ mkdir -p "${BUILDDIR}" || die
+}
+
+src_configure() {
+ cd "${BUILDDIR}" || die
+
+ ECONF_SOURCE="${S}/js/src" \
+ econf \
+ --disable-jemalloc \
+ --enable-readline \
+ --with-system-nspr \
+ --with-system-zlib \
+ --disable-optimize \
+ --with-intl-api \
+ $(use_with system-icu) \
+ $(use_enable debug) \
+ $(use_enable jit ion) \
+ $(use_enable test tests) \
+ XARGS="/usr/bin/xargs" \
+ CONFIG_SHELL="${EPREFIX}/bin/bash" \
+ CC="${CC}" CXX="${CXX}" LD="${LD}" AR="${AR}" RANLIB="${RANLIB}"
+}
+
+cross_make() {
+ emake \
+ CFLAGS="${BUILD_CFLAGS}" \
+ CXXFLAGS="${BUILD_CXXFLAGS}" \
+ AR="${BUILD_AR}" \
+ CC="${BUILD_CC}" \
+ CXX="${BUILD_CXX}" \
+ RANLIB="${BUILD_RANLIB}" \
+ "$@"
+}
+src_compile() {
+ cd "${BUILDDIR}" || die
+ if tc-is-cross-compiler; then
+ tc-export_build_env BUILD_{AR,CC,CXX,RANLIB}
+ cross_make \
+ MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" \
+ HOST_OPTIMIZE_FLAGS="" MODULE_OPTIMIZE_FLAGS="" \
+ MOZ_PGO_OPTIMIZE_FLAGS="" \
+ host_jsoplengen host_jskwgen
+ cross_make \
+ MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" HOST_OPTIMIZE_FLAGS="" \
+ -C config nsinstall
+ mv {,native-}host_jskwgen || die
+ mv {,native-}host_jsoplengen || die
+ mv config/{,native-}nsinstall || die
+ sed -i \
+ -e 's@./host_jskwgen@./native-host_jskwgen@' \
+ -e 's@./host_jsoplengen@./native-host_jsoplengen@' \
+ Makefile || die
+ sed -i -e 's@/nsinstall@/native-nsinstall@' config/config.mk || die
+ rm -f config/host_nsinstall.o \
+ config/host_pathsub.o \
+ host_jskwgen.o \
+ host_jsoplengen.o || die
+ fi
+
+ MOZ_MAKE_FLAGS="${MAKEOPTS}" \
+ emake \
+ MOZ_OPTIMIZE_FLAGS="" MOZ_DEBUG_FLAGS="" \
+ HOST_OPTIMIZE_FLAGS="" MODULE_OPTIMIZE_FLAGS="" \
+ MOZ_PGO_OPTIMIZE_FLAGS=""
+}
+
+src_test() {
+ cd "${BUILDDIR}/js/src/jsapi-tests" || die
+ ./jsapi-tests || die
+}
+
+src_install() {
+ cd "${BUILDDIR}" || die
+ emake DESTDIR="${D}" install
+
+ if ! use minimal; then
+ if use jit; then
+ pax-mark m "${ED}"usr/bin/js${SLOT}
+ fi
+ else
+ rm -f "${ED}"usr/bin/js${SLOT}
+ fi
+
+ # We can't actually disable building of static libraries
+ # They're used by the tests and in a few other places
+ find "${D}" -iname '*.a' -o -iname '*.ajs' -delete || die
+}