commit:     f86cb89cde8192adfdab42ee0b69109ddc12f1bd
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Wed Oct  7 01:01:00 2020 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Wed Oct  7 01:03:32 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f86cb89c

dev-lang/spidermonkey: add USE=lto

Forcing LTO via CFLAGS is not enough -- we need to tell build system
that we want to use LTO.

Closes: https://bugs.gentoo.org/746947
Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 dev-lang/spidermonkey/metadata.xml               |  1 +
 dev-lang/spidermonkey/spidermonkey-78.3.1.ebuild | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/dev-lang/spidermonkey/metadata.xml 
b/dev-lang/spidermonkey/metadata.xml
index fc9478d330b..c97143567bf 100644
--- a/dev-lang/spidermonkey/metadata.xml
+++ b/dev-lang/spidermonkey/metadata.xml
@@ -9,6 +9,7 @@
                <flag name="custom-optimization">Build with user-specified 
compiler optimizations
                        (-Os, -O0, -O1, -O2, -O3) from CFLAGS 
(unsupported)</flag>
                <flag name="debug">Enable assertions to allow for easier 
debugging of programs that link to spidermonkey -- note this will often crash 
software on regular end-user systems</flag>
+               <flag name="lto">Enable Link Time Optimization (LTO)</flag>
                <flag name="system-icu">Use the system-wide 
<pkg>dev-libs/icu</pkg> instead of bundled -- note, only takes effect when icu 
flag is enabled</flag>
        </use>
 </pkgmetadata>

diff --git a/dev-lang/spidermonkey/spidermonkey-78.3.1.ebuild 
b/dev-lang/spidermonkey/spidermonkey-78.3.1.ebuild
index a0ec34c118f..1694f51c184 100644
--- a/dev-lang/spidermonkey/spidermonkey-78.3.1.ebuild
+++ b/dev-lang/spidermonkey/spidermonkey-78.3.1.ebuild
@@ -7,7 +7,7 @@ PYTHON_COMPAT=( python3_{6..9} )
 
 WANT_AUTOCONF="2.1"
 
-inherit autotools check-reqs multiprocessing python-any-r1 toolchain-funcs
+inherit autotools check-reqs flag-o-matic multiprocessing python-any-r1 
toolchain-funcs
 
 MY_PN="mozjs"
 MY_PV="${PV/_pre*}" # Handle Gentoo pre-releases
@@ -53,7 +53,7 @@ KEYWORDS="~amd64 ~arm ~arm64 ~mips ~ppc64 ~s390 ~x86"
 
 SLOT="78"
 LICENSE="MPL-2.0"
-IUSE="cpu_flags_arm_neon debug +jit test"
+IUSE="cpu_flags_arm_neon debug +jit lto test"
 
 RESTRICT="!test? ( test )"
 
@@ -107,6 +107,8 @@ pkg_setup() {
 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
 
@@ -175,6 +177,14 @@ src_configure() {
                fi
        fi
 
+       # Tell build system that we want to use LTO
+       if use lto ; then
+               myeconfargs+=( --enable-lto )
+       fi
+
+       # LTO flag was handled via configure
+       filter-flags '-flto*'
+
        # Forcing system-icu allows us to skip patching bundled ICU for PPC
        # and other minor arches
        ECONF_SOURCE="${S}" \

Reply via email to