commit:     bcec88143087b45ba26f219efa76021e5acac391
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Sat Nov  9 11:29:09 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Sat Nov  9 11:57:50 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bcec8814

www-client/firefox: LTO Updates

Force LTO with USE=pgo

LTO now comes from CFLAGS, meaning that the REQUIRED_USE
previously enforcing this was removed in favour of
`eerror`. Instead we will force LTO even if it's not detected
from CFLAGS if PGO is in use.

Drop USE=lto on 128 to bring it into line with 132.

Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 www-client/firefox/firefox-128.4.0-r1.ebuild | 44 ++++++++++++++++++----------
 www-client/firefox/firefox-132.0-r1.ebuild   | 11 +++----
 www-client/firefox/firefox-132.0.1-r1.ebuild | 11 +++----
 3 files changed, 41 insertions(+), 25 deletions(-)

diff --git a/www-client/firefox/firefox-128.4.0-r1.ebuild 
b/www-client/firefox/firefox-128.4.0-r1.ebuild
index 1c04269f3aa9..3dbba65f6d4b 100644
--- a/www-client/firefox/firefox-128.4.0-r1.ebuild
+++ b/www-client/firefox/firefox-128.4.0-r1.ebuild
@@ -64,7 +64,7 @@ S="${WORKDIR}/${PN}-${PV%_*}"
 LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
 KEYWORDS="amd64 ~arm64 ~ppc64 ~riscv ~x86"
 
-IUSE="clang dbus debug eme-free hardened hwaccel jack +jumbo-build libproxy 
lto openh264 pgo"
+IUSE="clang dbus debug eme-free hardened hwaccel jack +jumbo-build libproxy 
openh264 pgo"
 IUSE+=" pulseaudio selinux sndio +system-av1 +system-harfbuzz +system-icu 
+system-jpeg"
 IUSE+=" +system-libevent +system-libvpx system-png +system-webp +telemetry 
wayland wifi +X"
 
@@ -73,7 +73,6 @@ IUSE+=" +gmp-autoupdate gnome-shell"
 
 REQUIRED_USE="|| ( X wayland )
        debug? ( !system-av1 )
-       pgo? ( lto )
        wayland? ( dbus )
        wifi? ( dbus )"
 
@@ -441,7 +440,7 @@ pkg_pretend() {
                fi
 
                # Ensure we have enough disk space to compile
-               if use pgo || use lto || use debug ; then
+               if use pgo || tc-is-lto || use debug ; then
                        CHECKREQS_DISK_BUILD="13500M"
                else
                        CHECKREQS_DISK_BUILD="6600M"
@@ -452,15 +451,34 @@ pkg_pretend() {
 }
 
 pkg_setup() {
+
+       # Get LTO from environment; export after this phase for use in 
src_configure (etc)
+       use_lto=no
+
        if [[ ${MERGE_TYPE} != binary ]] ; then
+
+               if tc-is-lto; then
+                       use_lto=yes
+                       # LTO is handled via configure
+                       # -Werror=lto-type-mismatch -Werror=odr are going to 
fail with GCC,
+                       # bmo#1516758, bgo#942288
+                       filter-lto
+                       filter-flags -Werror=lto-type-mismatch -Werror=odr
+               fi
+
                if use pgo ; then
+                       if [[ ${use_lto} == "no" ]]; then
+                               elog "Building ${PN} with USE=pgo requires LTO, 
however this was not detected in your environment."
+                               elog "Forcing LTO, however it is recommended to 
enable LTO explicitly."
+                               use_lto=yes
+                       fi
                        if ! has userpriv ${FEATURES} ; then
                                eerror "Building ${PN} with USE=pgo and 
FEATURES=-userpriv is not supported!"
                        fi
                fi
 
                # Ensure we have enough disk space to compile
-               if use pgo || use lto || use debug ; then
+               if use pgo || [[ ${use_lto} == "yes" ]] || use debug ; then
                        CHECKREQS_DISK_BUILD="13500M"
                else
                        CHECKREQS_DISK_BUILD="6400M"
@@ -471,7 +489,7 @@ pkg_setup() {
                llvm-r1_pkg_setup
                rust_pkg_setup
 
-               if use clang && use lto && tc-ld-is-lld ; then
+               if use clang && [[ ${use_lto} == "yes" ]] && tc-ld-is-lld ; 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!"
@@ -485,7 +503,7 @@ pkg_setup() {
                                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"
+                               eerror "  - Build ${CATEGORY}/${PN} without lto"
                                eerror "  - Rebuild lld with llvm that was used 
to build rust (may need to rebuild the whole "
                                eerror "    llvm/clang/lld/rust chain depending 
on your @world updates)"
                                die "LLVM version used by Rust 
(${version_llvm_rust}) does not match with ld.lld version (${version_lld})!"
@@ -546,6 +564,8 @@ pkg_setup() {
                export LC_ALL=C
        fi
 
+       export use_lto
+
        CONFIG_CHECK="~SECCOMP"
        WARNING_SECCOMP="CONFIG_SECCOMP not set! This system will be unable to 
play DRM-protected content."
        linux-info_pkg_setup
@@ -569,7 +589,7 @@ src_unpack() {
 }
 
 src_prepare() {
-       if use lto; then
+       if [[ ${use_lto} == "yes" ]]; then
                rm -v 
"${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die
        fi
 
@@ -899,13 +919,7 @@ src_configure() {
                mozconfig_add_options_ac '+x11' 
--enable-default-toolkit=cairo-gtk3-x11-only
        fi
 
-       # LTO is handled via configure.
-       # -Werror=lto-type-mismatch -Werror=odr are going to fail with GCC,
-       # bmo#1516758, bgo#942288
-       filter-lto
-       filter-flags -Werror=lto-type-mismatch -Werror=odr
-
-       if use lto ; then
+       if [[ ${use_lto} == "yes" ]]; then
                if use clang ; then
                        # Upstream only supports lld or mold when using clang.
                        if tc-ld-is-mold ; then
@@ -1080,7 +1094,7 @@ src_configure() {
 src_compile() {
        local virtx_cmd=
 
-       if tc-ld-is-mold && use lto; then
+       if tc-ld-is-mold && [[ ${use_lto} == "yes" ]]; then
                # increase ulimit with mold+lto, bugs #892641, #907485
                if ! ulimit -n 16384 1>/dev/null 2>&1 ; then
                        ewarn "Unable to modify ulimits - building with 
mold+lto might fail due to low ulimit -n resources."

diff --git a/www-client/firefox/firefox-132.0-r1.ebuild 
b/www-client/firefox/firefox-132.0-r1.ebuild
index 858c6586a808..42cdfb7c9604 100644
--- a/www-client/firefox/firefox-132.0-r1.ebuild
+++ b/www-client/firefox/firefox-132.0-r1.ebuild
@@ -472,9 +472,10 @@ pkg_setup() {
                fi
 
                if use pgo ; then
-                       if [[ ${use_lto} == "no" ]]; then
-                               eerror "Building ${PN} with USE=pgo requires 
LTO!"
-                               die "Please fix your CFLAGS/CXXFLAGS."
+                       if [[ ${use_lto} == "no" ]] ; then
+                               elog "Building ${PN} with USE=pgo requires LTO, 
however this was not detected in your environment."
+                               elog "Forcing LTO, however it is recommended to 
enable LTO explicitly."
+                               use_lto=yes
                        fi
                        if ! has userpriv ${FEATURES} ; then
                                eerror "Building ${PN} with USE=pgo and 
FEATURES=-userpriv is not supported!"
@@ -583,7 +584,7 @@ src_unpack() {
 }
 
 src_prepare() {
-       if [[ ${use_lto} = "yes" ]]; then
+       if [[ ${use_lto} == "yes" ]]; then
                rm -v 
"${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die
        fi
 
@@ -902,7 +903,7 @@ src_configure() {
                mozconfig_add_options_ac '+x11' 
--enable-default-toolkit=cairo-gtk3-x11-only
        fi
 
-       if [[ ${use_lto} = "yes" ]] ; then
+       if [[ ${use_lto} == "yes" ]] ; then
                if use clang ; then
                        # Upstream only supports lld or mold when using clang.
                        if tc-ld-is-mold ; then

diff --git a/www-client/firefox/firefox-132.0.1-r1.ebuild 
b/www-client/firefox/firefox-132.0.1-r1.ebuild
index c767c09e4a2a..56c448010e00 100644
--- a/www-client/firefox/firefox-132.0.1-r1.ebuild
+++ b/www-client/firefox/firefox-132.0.1-r1.ebuild
@@ -470,9 +470,10 @@ pkg_setup() {
                fi
 
                if use pgo ; then
-                       if [[ ${use_lto} == "no" ]]; then
-                               eerror "Building ${PN} with USE=pgo requires 
LTO!"
-                               die "Please fix your CFLAGS/CXXFLAGS."
+                       if [[ ${use_lto} == "no" ]] ; then
+                               elog "Building ${PN} with USE=pgo requires LTO, 
however this was not detected in your environment."
+                               elog "Forcing LTO, however it is recommended to 
enable LTO explicitly."
+                               use_lto=yes
                        fi
                        if ! has userpriv ${FEATURES} ; then
                                eerror "Building ${PN} with USE=pgo and 
FEATURES=-userpriv is not supported!"
@@ -581,7 +582,7 @@ src_unpack() {
 }
 
 src_prepare() {
-       if [[ ${use_lto} = "yes" ]]; then
+       if [[ ${use_lto} == "yes" ]]; then
                rm -v 
"${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die
        fi
 
@@ -900,7 +901,7 @@ src_configure() {
                mozconfig_add_options_ac '+x11' 
--enable-default-toolkit=cairo-gtk3-x11-only
        fi
 
-       if [[ ${use_lto} = "yes" ]] ; then
+       if [[ ${use_lto} == "yes" ]] ; then
                if use clang ; then
                        # Upstream only supports lld or mold when using clang.
                        if tc-ld-is-mold ; then

Reply via email to