From b8ad381b43f563634578d721a9571a6c36b778ad Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 30 Jul 2014 16:55:09 -0700 Subject: [PATCH 1/2] spidermonkey: Pull in upstream spidermonkey ebuild Required by polkit which defines policies in JavaScript. --- .../dev-lang/spidermonkey/Manifest | 1 + .../files/spidermonkey-17-ia64-mmap.patch | 67 +++++++++ .../spidermonkey-17-js-config-shebang.patch | 22 +++ ...ermonkey-17.0.0-fix-file-permissions.patch | 37 +++++ .../spidermonkey-17.0.0-r3.ebuild | 129 ++++++++++++++++++ 5 files changed, 256 insertions(+) create mode 100644 sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/Manifest create mode 100644 sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-js-config-shebang.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17.0.0-fix-file-permissions.patch create mode 100644 sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/Manifest b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/Manifest new file mode 100644 index 0000000000..7360105b6d --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/Manifest @@ -0,0 +1 @@ +DIST mozjs17.0.0.tar.gz 6778934 SHA256 321e964fe9386785d3bf80870640f2fa1c683e32fe988eeb201b04471c172fba SHA512 39b68aeb9f712f146778d8b68ee795709a1372c8ab893a222af4eb34882427d6f5cf877e743d6cb2f1b4348c194d8f3774f00cb775b03515b34b49560b748be4 WHIRLPOOL 4df7b51577787194065162b09d2c3dda849c13fa901305f9925d4ca5d38bb7f8e2daa943099e003fb9d11f9264ae2d77ccf04e5eea11e3ddcb624b504b99d52f diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch new file mode 100644 index 0000000000..7adbd118d4 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-ia64-mmap.patch @@ -0,0 +1,67 @@ +--- a/js/src/gc/Memory.cpp 2013-02-11 17:33:22.000000000 -0500 ++++ b/js/src/gc/Memory.cpp 2014-01-08 12:36:29.406851422 -0500 +@@ -302,10 +302,46 @@ + void + InitMemorySubsystem() + { ++#if !defined(__ia64__) + if (size_t(sysconf(_SC_PAGESIZE)) != PageSize) + MOZ_CRASH(); ++#endif + } + ++static inline void * ++MapMemory(size_t length, int prot, int flags, int fd, off_t offset) ++{ ++#if defined(__ia64__) ++ /* ++ * The JS engine assumes that all allocated pointers have their high 17 bits clear, ++ * which ia64's mmap doesn't support directly. However, we can emulate it by passing ++ * mmap an "addr" parameter with those bits clear. The mmap will return that address, ++ * or the nearest available memory above that address, providing a near-guarantee ++ * that those bits are clear. If they are not, we return NULL below to indicate ++ * out-of-memory. ++ * ++ * The addr is chosen as 0x0000070000000000, which still allows about 120TB of virtual ++ * address space. ++ * ++ * See Bug 589735 for more information. ++ */ ++ void *region = mmap((void*)0x0000070000000000, length, prot, flags, fd, offset); ++ if (region == MAP_FAILED) ++ return MAP_FAILED; ++ /* ++ * If the allocated memory doesn't have its upper 17 bits clear, consider it ++ * as out of memory. ++ */ ++ if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) { ++ JS_ALWAYS_TRUE(0 == munmap(region, length)); ++ return MAP_FAILED; ++ } ++ return region; ++#else ++ return mmap(NULL, length, prot, flags, fd, offset); ++#endif ++} ++ + void * + MapAlignedPages(size_t size, size_t alignment) + { +@@ -319,12 +353,15 @@ + + /* Special case: If we want page alignment, no further work is needed. */ + if (alignment == PageSize) { +- return mmap(NULL, size, prot, flags, -1, 0); ++ void *region = MapMemory(size, prot, flags, -1, 0); ++ if (region == MAP_FAILED) ++ return NULL; ++ return region; + } + + /* Overallocate and unmap the region's edges. */ + size_t reqSize = Min(size + 2 * alignment, 2 * size); +- void *region = mmap(NULL, reqSize, prot, flags, -1, 0); ++ void *region = MapMemory(reqSize, prot, flags, -1, 0); + if (region == MAP_FAILED) + return NULL; + diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-js-config-shebang.patch b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-js-config-shebang.patch new file mode 100644 index 0000000000..ec77b23682 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17-js-config-shebang.patch @@ -0,0 +1,22 @@ +--- a/js/src/js-config.in 2013-03-25 16:34:20.000000000 -0400 ++++ b/js/src/js-config.in 2013-08-09 22:15:29.000901763 -0400 +@@ -2,7 +2,7 @@ + # This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. +-#filter substitution ++%filter substitution + + prefix='@prefix@' + mozilla_version='@MOZILLA_VERSION@' +--- a/js/src/Makefile.in 2013-03-25 16:34:20.000000000 -0400 ++++ b/js/src/Makefile.in 2013-08-09 22:17:20.211903793 -0400 +@@ -778,7 +778,7 @@ + + $(JS_CONFIG_NAME): js-config.in Makefile $(DEPTH)/config/autoconf.mk $(topsrcdir)/config/config.mk $(topsrcdir)/config/rules.mk + $(RM) $@.tmp +- $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(JS_CONFIG_SUBSTITUTIONS) $< > $@.tmp \ ++ $(PYTHON) $(topsrcdir)/config/Preprocessor.py --marker="%" $(JS_CONFIG_SUBSTITUTIONS) $< > $@.tmp \ + && mv $@.tmp $@ && chmod +x $@ + + SCRIPTS = $(JS_CONFIG_NAME) diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17.0.0-fix-file-permissions.patch b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17.0.0-fix-file-permissions.patch new file mode 100644 index 0000000000..f4eee93054 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/files/spidermonkey-17.0.0-fix-file-permissions.patch @@ -0,0 +1,37 @@ +diff -urN a/js/src/Makefile.in b/js/src/Makefile.in +--- a/js/src/Makefile.in 2013-03-25 15:34:20.000000000 -0500 ++++ b/js/src/Makefile.in 2014-03-08 08:26:36.726979744 -0600 +@@ -788,7 +788,7 @@ + $(PYTHON) $(topsrcdir)/config/Preprocessor.py $(JS_CONFIG_SUBSTITUTIONS) $< > $@ + + install:: $(LIBRARY_NAME).pc +- $(SYSINSTALL) $^ $(DESTDIR)$(libdir)/pkgconfig ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(libdir)/pkgconfig + + ###################################################### + # BEGIN SpiderMonkey header installation +@@ -836,19 +836,19 @@ + # + + install:: $(INSTALLED_HEADERS) +- $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE) ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(includedir)/$(MODULE) + + install:: $(EXPORTS_ds) +- $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE)/ds ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(includedir)/$(MODULE)/ds + + install:: $(EXPORTS_gc) +- $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE)/gc ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(includedir)/$(MODULE)/gc + + install:: $(EXPORTS_js) +- $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE)/js ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(includedir)/$(MODULE)/js + + install:: $(EXPORTS_mozilla) +- $(SYSINSTALL) $^ $(DESTDIR)$(includedir)/$(MODULE)/mozilla ++ $(SYSINSTALL) -m 0644 $^ $(DESTDIR)$(includedir)/$(MODULE)/mozilla + + # + # END SpiderMonkey header installation diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild new file mode 100644 index 0000000000..6fdfce9819 --- /dev/null +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild @@ -0,0 +1,129 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild,v 1.7 2014/04/19 17:43:30 ago Exp $ + +EAPI="5" +WANT_AUTOCONF="2.1" +PYTHON_COMPAT=( python2_{6,7} ) +PYTHON_REQ_USE="threads" +inherit eutils toolchain-funcs multilib python-any-r1 versionator pax-utils + +MY_PN="mozjs" +MY_P="${MY_PN}${PV}" +DESCRIPTION="Stand-alone JavaScript C library" +HOMEPAGE="http://www.mozilla.org/js/spidermonkey/" +SRC_URI="http://ftp.mozilla.org/pub/mozilla.org/js/${MY_PN}${PV}.tar.gz" + +LICENSE="NPL-1.1" +SLOT="17" +# "MIPS, MacroAssembler is not supported" wrt #491294 for -mips +KEYWORDS="alpha amd64 arm -hppa ia64 -mips ppc ppc64 ~s390 ~sh sparc x86 ~x86-fbsd" +IUSE="debug jit minimal static-libs test" + +REQUIRED_USE="debug? ( jit )" +RESTRICT="ia64? ( test )" + +S="${WORKDIR}/${MY_P}" +BUILDDIR="${S}/js/src" + +RDEPEND=">=dev-libs/nspr-4.9.4 + virtual/libffi + >=sys-libs/zlib-1.1.4" +DEPEND="${RDEPEND} + ${PYTHON_DEPS} + app-arch/zip + virtual/pkgconfig" + +pkg_setup(){ + if [[ ${MERGE_TYPE} != "binary" ]]; then + python-any-r1_pkg_setup + export LC_ALL="C" + fi +} + +src_prepare() { + epatch "${FILESDIR}"/${PN}-${SLOT}-js-config-shebang.patch + epatch "${FILESDIR}"/${PN}-${SLOT}-ia64-mmap.patch + epatch "${FILESDIR}"/${PN}-17.0.0-fix-file-permissions.patch + # Remove obsolete jsuword bug #506160 + sed -i -e '/jsuword/d' "${BUILDDIR}"/jsval.h ||die "sed failed" + epatch_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 +} + +src_configure() { + cd "${BUILDDIR}" || die + + CC="$(tc-getCC)" CXX="$(tc-getCXX)" \ + AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" \ + LD="$(tc-getLD)" \ + econf \ + ${myopts} \ + --enable-jemalloc \ + --enable-readline \ + --enable-threadsafe \ + --with-system-nspr \ + --enable-system-ffi \ + --enable-jemalloc \ + $(use_enable debug) \ + $(use_enable jit tracejit) \ + $(use_enable jit methodjit) \ + $(use_enable static-libs static) \ + $(use_enable test tests) +} + +src_compile() { + cd "${BUILDDIR}" || die + if tc-is-cross-compiler; then + make CFLAGS="" CXXFLAGS="" \ + CC=$(tc-getBUILD_CC) CXX=$(tc-getBUILD_CXX) \ + AR=$(tc-getBUILD_AR) RANLIB=$(tc-getBUILD_RANLIB) \ + jscpucfg host_jsoplengen host_jskwgen || die + make CFLAGS="" CXXFLAGS="" \ + CC=$(tc-getBUILD_CC) CXX=$(tc-getBUILD_CXX) \ + AR=$(tc-getBUILD_AR) RANLIB=$(tc-getBUILD_RANLIB) \ + -C config nsinstall || die + mv {,native-}jscpucfg || die + mv {,native-}host_jskwgen || die + mv {,native-}host_jsoplengen || die + mv config/{,native-}nsinstall || die + sed -e 's@./jscpucfg@./native-jscpucfg@' \ + -e 's@./host_jskwgen@./native-host_jskwgen@' \ + -e 's@./host_jsoplengen@./native-host_jsoplengen@' \ + -i Makefile || die + sed -e 's@/nsinstall@/native-nsinstall@' -i config/config.mk || die + rm -f config/host_nsinstall.o \ + config/host_pathsub.o \ + host_jskwgen.o \ + host_jsoplengen.o || die + fi + emake +} + +src_test() { + cd "${BUILDDIR}/jsapi-tests" || die + emake check +} + +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 + + if ! use static-libs; then + # 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' -delete || die + fi +} From a047717347ef856a7925e9597c0b0bd7040b3466 Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Wed, 30 Jul 2014 16:57:43 -0700 Subject: [PATCH 2/2] spidermonkey: fix cross-compiling logic The existing ebuild uses a really crazy hack for cross compiling which may have worked a few versions ago but it doesn't now. The root issue is that Mozilla mixes up the meaning of "host" and "target" so give in to their stupid and setup the environment with their meaning. The configure script claimed in a comment: In Mozilla, we use the names $target, $host and $build incorrectly, but are too far gone to back out now. See Bug 475488: - When we say $target, we mean $host, that is, the system on which Mozilla will be run. - When we say $host, we mean $build, that is, the system on which Mozilla is built. - $target (in its correct usage) is for compilers who generate code for a different platform than $host, so it would not be used by Mozilla. I'm inclined to smack someone with a stick. --- ...3.ebuild => spidermonkey-17.0.0-r4.ebuild} | 44 +++++++------------ .../profiles/coreos/base/package.use | 2 + 2 files changed, 18 insertions(+), 28 deletions(-) rename sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/{spidermonkey-17.0.0-r3.ebuild => spidermonkey-17.0.0-r4.ebuild} (70%) diff --git a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r4.ebuild similarity index 70% rename from sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild rename to sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r4.ebuild index 6fdfce9819..344ee5b0b9 100644 --- a/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r3.ebuild +++ b/sdk_container/src/third_party/coreos-overlay/dev-lang/spidermonkey/spidermonkey-17.0.0-r4.ebuild @@ -58,17 +58,28 @@ src_prepare() { src_configure() { cd "${BUILDDIR}" || die - CC="$(tc-getCC)" CXX="$(tc-getCXX)" \ - AR="$(tc-getAR)" RANLIB="$(tc-getRANLIB)" \ - LD="$(tc-getLD)" \ + # Mozilla screws up the meaning of BUILD, HOST, and TARGET :( + tc-export_build_env CC CXX LD AR RANLIB PKG_CONFIG \ + BUILD_CC BUILD_CXX BUILD_LD BUILD_AR BUILD_RANLIB + export HOST_CC="${BUILD_CC}" HOST_CFLAGS="${BUILD_CFLAGS}" \ + HOST_CXX="${BUILD_CXX}" HOST_CXXFLAGS="${BUILD_CXXFLAGS}" \ + HOST_LD="${BUILD_LD}" HOST_LDFLAGS="${BUILD_LDFLAGS}" \ + HOST_AR="${BUILD_AR}" HOST_RANLIB="${BUILD_RANLIB}" + + # Use pkg-config instead of nspr-config to use $SYSROOT + local nspr_cflags="$(${PKG_CONFIG} --cflags nspr)" || die + local nspr_libs="$(${PKG_CONFIG} --libs nspr)" || die + econf \ ${myopts} \ + --host="${CBUILD}" \ + --target="${CHOST}" \ --enable-jemalloc \ --enable-readline \ --enable-threadsafe \ - --with-system-nspr \ --enable-system-ffi \ - --enable-jemalloc \ + --with-nspr-cflags="${nspr_cflags}" \ + --with-nspr-libs="${nspr_libs}" \ $(use_enable debug) \ $(use_enable jit tracejit) \ $(use_enable jit methodjit) \ @@ -78,29 +89,6 @@ src_configure() { src_compile() { cd "${BUILDDIR}" || die - if tc-is-cross-compiler; then - make CFLAGS="" CXXFLAGS="" \ - CC=$(tc-getBUILD_CC) CXX=$(tc-getBUILD_CXX) \ - AR=$(tc-getBUILD_AR) RANLIB=$(tc-getBUILD_RANLIB) \ - jscpucfg host_jsoplengen host_jskwgen || die - make CFLAGS="" CXXFLAGS="" \ - CC=$(tc-getBUILD_CC) CXX=$(tc-getBUILD_CXX) \ - AR=$(tc-getBUILD_AR) RANLIB=$(tc-getBUILD_RANLIB) \ - -C config nsinstall || die - mv {,native-}jscpucfg || die - mv {,native-}host_jskwgen || die - mv {,native-}host_jsoplengen || die - mv config/{,native-}nsinstall || die - sed -e 's@./jscpucfg@./native-jscpucfg@' \ - -e 's@./host_jskwgen@./native-host_jskwgen@' \ - -e 's@./host_jsoplengen@./native-host_jsoplengen@' \ - -i Makefile || die - sed -e 's@/nsinstall@/native-nsinstall@' -i config/config.mk || die - rm -f config/host_nsinstall.o \ - config/host_pathsub.o \ - host_jskwgen.o \ - host_jsoplengen.o || die - fi emake } diff --git a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.use b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.use index c5f0e50d90..d63a0dcc2e 100644 --- a/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.use +++ b/sdk_container/src/third_party/coreos-overlay/profiles/coreos/base/package.use @@ -81,3 +81,5 @@ sys-apps/systemd -ssl # disable kernel config detection and module building net-firewall/ipset -modules + +dev-lang/spidermonkey minimal