commit:     5938cb614d0197d07fb315fc459649dfc1d59ba3
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  6 21:33:30 2026 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Fri Mar  6 22:02:00 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5938cb61

www-client/chromium: disable lto on aarch64 && LLVM 21

LTO seems to crash the linker and we don't have any easy way to bisect
on aarch64.

As part of this, pkg_setup has been reformatted across all ebuilds for
consistency (and because we needed to suppress the USE=official LTO
warning).

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

 www-client/chromium/chromium-145.0.7632.109.ebuild | 65 ++++++++++++---------
 www-client/chromium/chromium-145.0.7632.159.ebuild | 67 +++++++++++++---------
 .../chromium/chromium-146.0.7680.31-r2.ebuild      | 67 +++++++++++++---------
 www-client/chromium/chromium-146.0.7680.65.ebuild  | 67 +++++++++++++---------
 .../chromium/chromium-147.0.7703.0-r1.ebuild       | 67 +++++++++++++---------
 5 files changed, 193 insertions(+), 140 deletions(-)

diff --git a/www-client/chromium/chromium-145.0.7632.109.ebuild 
b/www-client/chromium/chromium-145.0.7632.109.ebuild
index add1b8e0d414..7c4526d87d67 100644
--- a/www-client/chromium/chromium-145.0.7632.109.ebuild
+++ b/www-client/chromium/chromium-145.0.7632.109.ebuild
@@ -89,7 +89,8 @@ IUSE="+X ${IUSE_SYSTEM_LIBS} bindist bundled-toolchain cups 
debug ffmpeg-chromiu
 IUSE+=" +proprietary-codecs pulseaudio qt6 +rar +screencast selinux test 
+vaapi +wayland +widevine cpu_flags_ppc_vsx3"
 RESTRICT="
        !bindist? ( bindist )
-       !test? ( test )" # Since M142 tests have been segfaulting on Gentoo 
systems; disabling for now.
+       !test? ( test )
+       arm64? ( test )" # Tests require CFI, which requires LTO, which is 
broken on arm64 with LLVM 21.
 
 REQUIRED_USE="
        !headless? ( || ( X wayland ) )
@@ -314,26 +315,47 @@ pkg_setup() {
                # The pre_build_checks are all about compilation resources, no 
need to run it for a binpkg
                pre_build_checks
 
+               # We haven't massaged any CFLAGS yet, so we want to do this 
before we force CC/CXX to prevent warnings.
+               local want_lto="false"
+               tc-is-lto && want_lto="true"
+
                # The linux:unbundle toolchain in GN grabs CC, CXX, CPP (etc) 
from the environment
                # We'll set these to clang here then use llvm-utils functions 
to very explicitly set these
                # to a sane value.
                # This is effectively the 'force-clang' path if GCC support is 
re-added.
-               # TODO: check if the user has already selected a specific impl 
via make.conf and respect that.
+               if use !bundled-toolchain; then
+                       llvm-r1_pkg_setup
+                       rust_pkg_setup
+
+                       # Forcing clang; respect llvm_slot_x to enable 
selection of impl via LLVM_COMPAT
+                       AR=llvm-ar
+                       CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
+                       NM=llvm-nm
+                       CC="${CHOST}-clang-${LLVM_SLOT}"
+                       CXX="${CHOST}-clang++-${LLVM_SLOT}"
+               fi
+
                use_lto="false"
-               if tc-is-lto; then
-                       use_lto="true"
-                       # We can rely on GN to do this for us; anecdotally 
without this builds
-                       # take significantly longer with LTO enabled and it 
doesn't hurt anything.
+               local lto_usable="true"
+               if [[ "$want_lto" == "true" ]]; then
+                       if use arm64 && [[ "${LLVM_SLOT}" -lt 22 ]]; then
+                               einfo "LTO is broken with LLVM 21 on arm64, 
ignoring CFLAGS."
+                               lto_usable="false"
+                       else
+                               use_lto="true"
+                       fi
+                       # We can rely on GN to do this for us; without this 
builds
+                       # take significantly longer with LTO enabled.
                        filter-lto
                fi
 
-               if [ "$use_lto" = "false" ] && use official; then
+               if [[ "$use_lto" == "false" ]] && use official && [[ 
"$lto_usable" == "true" ]]; then
                        einfo "USE=official selected and LTO not detected."
                        einfo "It is _highly_ recommended that LTO be enabled 
for performance reasons"
                        einfo "and to be consistent with the upstream 
\"official\" build optimisations."
                fi
 
-               if [ "$use_lto" = "false" ] && use test; then
+               if [[ "$use_lto" == "false" ]] && use test; then
                        die "Tests require CFI which requires LTO"
                fi
 
@@ -346,25 +368,6 @@ pkg_setup() {
                        die "Please switch to a different linker."
                fi
 
-               if use !bundled-toolchain; then
-                       llvm-r1_pkg_setup
-                       rust_pkg_setup
-               fi
-
-               # Forcing clang; respect llvm_slot_x to enable selection of 
impl from LLVM_COMPAT
-               AR=llvm-ar
-               CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
-               NM=llvm-nm
-               CC="${CHOST}-clang-${LLVM_SLOT}"
-               CXX="${CHOST}-clang++-${LLVM_SLOT}"
-
-               # Sanity check our linker here; sometimes when adding a new 
LLVM slot devs (me) forget
-               # to install an appropriate lld version. llvm-r1_pkg_setup 
prefixed PATH for us, so it should be there.
-               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
-               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
-                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
-               fi
-
                if tc-is-cross-compiler; then
                        use pgo && die "The pgo USE flag cannot be used when 
cross-compiling"
                        CPP="${CBUILD}-clang++-${LLVM_SLOT} -E"
@@ -374,10 +377,16 @@ pkg_setup() {
                # us poor packagers. Required for Split LTO units, which are 
required for CFI.
                export RUSTC_BOOTSTRAP=1
 
-               # Users should never hit this, it's purely a development 
convenience
+               # Sanity checks for development convenience
                if ver_test $(gn --version || die) -lt ${GN_MIN_VER}; then
                        die "dev-build/gn >= ${GN_MIN_VER} is required to build 
this Chromium"
                fi
+
+               # Sometimes, when adding a new LLVM slot, devs (me) forget to 
install an appropriate lld.
+               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
+               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
+                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
+               fi
        fi
 
        chromium_suid_sandbox_check_kernel_config

diff --git a/www-client/chromium/chromium-145.0.7632.159.ebuild 
b/www-client/chromium/chromium-145.0.7632.159.ebuild
index 6f0f9cec6eb4..297600f65dc2 100644
--- a/www-client/chromium/chromium-145.0.7632.159.ebuild
+++ b/www-client/chromium/chromium-145.0.7632.159.ebuild
@@ -91,7 +91,10 @@ KEYWORDS="amd64 ~arm64 ~ppc64"
 IUSE_SYSTEM_LIBS="+system-harfbuzz +system-icu +system-zstd"
 IUSE="+X ${IUSE_SYSTEM_LIBS} bindist bundled-toolchain cups debug 
ffmpeg-chromium gtk4 +hangouts headless kerberos +official pax-kernel pgo"
 IUSE+=" +proprietary-codecs pulseaudio qt6 +rar +screencast selinux test 
+vaapi +wayland +widevine cpu_flags_ppc_vsx3"
-RESTRICT="!bindist? ( bindist ) !test? ( test )"
+RESTRICT="
+       !bindist? ( bindist )
+       !test? ( test )
+       arm64? ( test )" # Tests require CFI, which requires LTO, which is 
broken on arm64 with LLVM 21.
 
 REQUIRED_USE="
        !headless? ( || ( X wayland ) )
@@ -318,26 +321,47 @@ pkg_setup() {
                # The pre_build_checks are all about compilation resources, no 
need to run it for a binpkg
                pre_build_checks
 
+               # We haven't massaged any CFLAGS yet, so we want to do this 
before we force CC/CXX to prevent warnings.
+               local want_lto="false"
+               tc-is-lto && want_lto="true"
+
                # The linux:unbundle toolchain in GN grabs CC, CXX, CPP (etc) 
from the environment
                # We'll set these to clang here then use llvm-utils functions 
to very explicitly set these
                # to a sane value.
                # This is effectively the 'force-clang' path if GCC support is 
re-added.
-               # TODO: check if the user has already selected a specific impl 
via make.conf and respect that.
+               if use !bundled-toolchain; then
+                       llvm-r1_pkg_setup
+                       rust_pkg_setup
+
+                       # Forcing clang; respect llvm_slot_x to enable 
selection of impl via LLVM_COMPAT
+                       AR=llvm-ar
+                       CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
+                       NM=llvm-nm
+                       CC="${CHOST}-clang-${LLVM_SLOT}"
+                       CXX="${CHOST}-clang++-${LLVM_SLOT}"
+               fi
+
                use_lto="false"
-               if tc-is-lto; then
-                       use_lto="true"
-                       # We can rely on GN to do this for us; anecdotally 
without this builds
-                       # take significantly longer with LTO enabled and it 
doesn't hurt anything.
+               local lto_usable="true"
+               if [[ "$want_lto" == "true" ]]; then
+                       if use arm64 && [[ "${LLVM_SLOT}" -lt 22 ]]; then
+                               einfo "LTO is broken with LLVM 21 on arm64, 
ignoring CFLAGS."
+                               lto_usable="false"
+                       else
+                               use_lto="true"
+                       fi
+                       # We can rely on GN to do this for us; without this 
builds
+                       # take significantly longer with LTO enabled.
                        filter-lto
                fi
 
-               if [ "$use_lto" = "false" ] && use official; then
+               if [[ "$use_lto" == "false" ]] && use official && [[ 
"$lto_usable" == "true" ]]; then
                        einfo "USE=official selected and LTO not detected."
                        einfo "It is _highly_ recommended that LTO be enabled 
for performance reasons"
                        einfo "and to be consistent with the upstream 
\"official\" build optimisations."
                fi
 
-               if [ "$use_lto" = "false" ] && use test; then
+               if [[ "$use_lto" == "false" ]] && use test; then
                        die "Tests require CFI which requires LTO"
                fi
 
@@ -350,25 +374,6 @@ pkg_setup() {
                        die "Please switch to a different linker."
                fi
 
-               if use !bundled-toolchain; then
-                       llvm-r1_pkg_setup
-                       rust_pkg_setup
-               fi
-
-               # Forcing clang; respect llvm_slot_x to enable selection of 
impl from LLVM_COMPAT
-               AR=llvm-ar
-               CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
-               NM=llvm-nm
-               CC="${CHOST}-clang-${LLVM_SLOT}"
-               CXX="${CHOST}-clang++-${LLVM_SLOT}"
-
-               # Sanity check our linker here; sometimes when adding a new 
LLVM slot devs (me) forget
-               # to install an appropriate lld version. llvm-r1_pkg_setup 
prefixed PATH for us, so it should be there.
-               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
-               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
-                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
-               fi
-
                if tc-is-cross-compiler; then
                        use pgo && die "The pgo USE flag cannot be used when 
cross-compiling"
                        CPP="${CBUILD}-clang++-${LLVM_SLOT} -E"
@@ -378,10 +383,16 @@ pkg_setup() {
                # us poor packagers. Required for Split LTO units, which are 
required for CFI.
                export RUSTC_BOOTSTRAP=1
 
-               # Users should never hit this, it's purely a development 
convenience
+               # Sanity checks for development convenience
                if ver_test $(gn --version || die) -lt ${GN_MIN_VER}; then
                        die "dev-build/gn >= ${GN_MIN_VER} is required to build 
this Chromium"
                fi
+
+               # Sometimes, when adding a new LLVM slot, devs (me) forget to 
install an appropriate lld.
+               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
+               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
+                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
+               fi
        fi
 
        chromium_suid_sandbox_check_kernel_config

diff --git a/www-client/chromium/chromium-146.0.7680.31-r2.ebuild 
b/www-client/chromium/chromium-146.0.7680.31-r2.ebuild
index de3a762b2d0e..b3ff834ef508 100644
--- a/www-client/chromium/chromium-146.0.7680.31-r2.ebuild
+++ b/www-client/chromium/chromium-146.0.7680.31-r2.ebuild
@@ -91,7 +91,10 @@ KEYWORDS="~amd64 ~arm64"
 IUSE_SYSTEM_LIBS="+system-harfbuzz +system-icu +system-zstd"
 IUSE="+X ${IUSE_SYSTEM_LIBS} bindist bundled-toolchain cups debug 
ffmpeg-chromium gtk4 +hangouts headless kerberos +official pax-kernel pgo"
 IUSE+=" +proprietary-codecs pulseaudio qt6 +rar +screencast selinux test 
+vaapi +wayland +widevine cpu_flags_ppc_vsx3"
-RESTRICT="!bindist? ( bindist ) !test? ( test )"
+RESTRICT="
+       !bindist? ( bindist )
+       !test? ( test )
+       arm64? ( test )" # Tests require CFI, which requires LTO, which is 
broken on arm64 with LLVM 21.
 
 REQUIRED_USE="
        !headless? ( || ( X wayland ) )
@@ -318,26 +321,47 @@ pkg_setup() {
                # The pre_build_checks are all about compilation resources, no 
need to run it for a binpkg
                pre_build_checks
 
+               # We haven't massaged any CFLAGS yet, so we want to do this 
before we force CC/CXX to prevent warnings.
+               local want_lto="false"
+               tc-is-lto && want_lto="true"
+
                # The linux:unbundle toolchain in GN grabs CC, CXX, CPP (etc) 
from the environment
                # We'll set these to clang here then use llvm-utils functions 
to very explicitly set these
                # to a sane value.
                # This is effectively the 'force-clang' path if GCC support is 
re-added.
-               # TODO: check if the user has already selected a specific impl 
via make.conf and respect that.
+               if use !bundled-toolchain; then
+                       llvm-r1_pkg_setup
+                       rust_pkg_setup
+
+                       # Forcing clang; respect llvm_slot_x to enable 
selection of impl via LLVM_COMPAT
+                       AR=llvm-ar
+                       CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
+                       NM=llvm-nm
+                       CC="${CHOST}-clang-${LLVM_SLOT}"
+                       CXX="${CHOST}-clang++-${LLVM_SLOT}"
+               fi
+
                use_lto="false"
-               if tc-is-lto; then
-                       use_lto="true"
-                       # We can rely on GN to do this for us; anecdotally 
without this builds
-                       # take significantly longer with LTO enabled and it 
doesn't hurt anything.
+               local lto_usable="true"
+               if [[ "$want_lto" == "true" ]]; then
+                       if use arm64 && [[ "${LLVM_SLOT}" -lt 22 ]]; then
+                               einfo "LTO is broken with LLVM 21 on arm64, 
ignoring CFLAGS."
+                               lto_usable="false"
+                       else
+                               use_lto="true"
+                       fi
+                       # We can rely on GN to do this for us; without this 
builds
+                       # take significantly longer with LTO enabled.
                        filter-lto
                fi
 
-               if [ "$use_lto" = "false" ] && use official; then
+               if [[ "$use_lto" == "false" ]] && use official && [[ 
"$lto_usable" == "true" ]]; then
                        einfo "USE=official selected and LTO not detected."
                        einfo "It is _highly_ recommended that LTO be enabled 
for performance reasons"
                        einfo "and to be consistent with the upstream 
\"official\" build optimisations."
                fi
 
-               if [ "$use_lto" = "false" ] && use test; then
+               if [[ "$use_lto" == "false" ]] && use test; then
                        die "Tests require CFI which requires LTO"
                fi
 
@@ -350,25 +374,6 @@ pkg_setup() {
                        die "Please switch to a different linker."
                fi
 
-               if use !bundled-toolchain; then
-                       llvm-r1_pkg_setup
-                       rust_pkg_setup
-               fi
-
-               # Forcing clang; respect llvm_slot_x to enable selection of 
impl from LLVM_COMPAT
-               AR=llvm-ar
-               CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
-               NM=llvm-nm
-               CC="${CHOST}-clang-${LLVM_SLOT}"
-               CXX="${CHOST}-clang++-${LLVM_SLOT}"
-
-               # Sanity check our linker here; sometimes when adding a new 
LLVM slot devs (me) forget
-               # to install an appropriate lld version. llvm-r1_pkg_setup 
prefixed PATH for us, so it should be there.
-               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
-               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
-                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
-               fi
-
                if tc-is-cross-compiler; then
                        use pgo && die "The pgo USE flag cannot be used when 
cross-compiling"
                        CPP="${CBUILD}-clang++-${LLVM_SLOT} -E"
@@ -378,10 +383,16 @@ pkg_setup() {
                # us poor packagers. Required for Split LTO units, which are 
required for CFI.
                export RUSTC_BOOTSTRAP=1
 
-               # Users should never hit this, it's purely a development 
convenience
+               # Sanity checks for development convenience
                if ver_test $(gn --version || die) -lt ${GN_MIN_VER}; then
                        die "dev-build/gn >= ${GN_MIN_VER} is required to build 
this Chromium"
                fi
+
+               # Sometimes, when adding a new LLVM slot, devs (me) forget to 
install an appropriate lld.
+               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
+               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
+                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
+               fi
        fi
 
        chromium_suid_sandbox_check_kernel_config

diff --git a/www-client/chromium/chromium-146.0.7680.65.ebuild 
b/www-client/chromium/chromium-146.0.7680.65.ebuild
index de3a762b2d0e..b3ff834ef508 100644
--- a/www-client/chromium/chromium-146.0.7680.65.ebuild
+++ b/www-client/chromium/chromium-146.0.7680.65.ebuild
@@ -91,7 +91,10 @@ KEYWORDS="~amd64 ~arm64"
 IUSE_SYSTEM_LIBS="+system-harfbuzz +system-icu +system-zstd"
 IUSE="+X ${IUSE_SYSTEM_LIBS} bindist bundled-toolchain cups debug 
ffmpeg-chromium gtk4 +hangouts headless kerberos +official pax-kernel pgo"
 IUSE+=" +proprietary-codecs pulseaudio qt6 +rar +screencast selinux test 
+vaapi +wayland +widevine cpu_flags_ppc_vsx3"
-RESTRICT="!bindist? ( bindist ) !test? ( test )"
+RESTRICT="
+       !bindist? ( bindist )
+       !test? ( test )
+       arm64? ( test )" # Tests require CFI, which requires LTO, which is 
broken on arm64 with LLVM 21.
 
 REQUIRED_USE="
        !headless? ( || ( X wayland ) )
@@ -318,26 +321,47 @@ pkg_setup() {
                # The pre_build_checks are all about compilation resources, no 
need to run it for a binpkg
                pre_build_checks
 
+               # We haven't massaged any CFLAGS yet, so we want to do this 
before we force CC/CXX to prevent warnings.
+               local want_lto="false"
+               tc-is-lto && want_lto="true"
+
                # The linux:unbundle toolchain in GN grabs CC, CXX, CPP (etc) 
from the environment
                # We'll set these to clang here then use llvm-utils functions 
to very explicitly set these
                # to a sane value.
                # This is effectively the 'force-clang' path if GCC support is 
re-added.
-               # TODO: check if the user has already selected a specific impl 
via make.conf and respect that.
+               if use !bundled-toolchain; then
+                       llvm-r1_pkg_setup
+                       rust_pkg_setup
+
+                       # Forcing clang; respect llvm_slot_x to enable 
selection of impl via LLVM_COMPAT
+                       AR=llvm-ar
+                       CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
+                       NM=llvm-nm
+                       CC="${CHOST}-clang-${LLVM_SLOT}"
+                       CXX="${CHOST}-clang++-${LLVM_SLOT}"
+               fi
+
                use_lto="false"
-               if tc-is-lto; then
-                       use_lto="true"
-                       # We can rely on GN to do this for us; anecdotally 
without this builds
-                       # take significantly longer with LTO enabled and it 
doesn't hurt anything.
+               local lto_usable="true"
+               if [[ "$want_lto" == "true" ]]; then
+                       if use arm64 && [[ "${LLVM_SLOT}" -lt 22 ]]; then
+                               einfo "LTO is broken with LLVM 21 on arm64, 
ignoring CFLAGS."
+                               lto_usable="false"
+                       else
+                               use_lto="true"
+                       fi
+                       # We can rely on GN to do this for us; without this 
builds
+                       # take significantly longer with LTO enabled.
                        filter-lto
                fi
 
-               if [ "$use_lto" = "false" ] && use official; then
+               if [[ "$use_lto" == "false" ]] && use official && [[ 
"$lto_usable" == "true" ]]; then
                        einfo "USE=official selected and LTO not detected."
                        einfo "It is _highly_ recommended that LTO be enabled 
for performance reasons"
                        einfo "and to be consistent with the upstream 
\"official\" build optimisations."
                fi
 
-               if [ "$use_lto" = "false" ] && use test; then
+               if [[ "$use_lto" == "false" ]] && use test; then
                        die "Tests require CFI which requires LTO"
                fi
 
@@ -350,25 +374,6 @@ pkg_setup() {
                        die "Please switch to a different linker."
                fi
 
-               if use !bundled-toolchain; then
-                       llvm-r1_pkg_setup
-                       rust_pkg_setup
-               fi
-
-               # Forcing clang; respect llvm_slot_x to enable selection of 
impl from LLVM_COMPAT
-               AR=llvm-ar
-               CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
-               NM=llvm-nm
-               CC="${CHOST}-clang-${LLVM_SLOT}"
-               CXX="${CHOST}-clang++-${LLVM_SLOT}"
-
-               # Sanity check our linker here; sometimes when adding a new 
LLVM slot devs (me) forget
-               # to install an appropriate lld version. llvm-r1_pkg_setup 
prefixed PATH for us, so it should be there.
-               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
-               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
-                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
-               fi
-
                if tc-is-cross-compiler; then
                        use pgo && die "The pgo USE flag cannot be used when 
cross-compiling"
                        CPP="${CBUILD}-clang++-${LLVM_SLOT} -E"
@@ -378,10 +383,16 @@ pkg_setup() {
                # us poor packagers. Required for Split LTO units, which are 
required for CFI.
                export RUSTC_BOOTSTRAP=1
 
-               # Users should never hit this, it's purely a development 
convenience
+               # Sanity checks for development convenience
                if ver_test $(gn --version || die) -lt ${GN_MIN_VER}; then
                        die "dev-build/gn >= ${GN_MIN_VER} is required to build 
this Chromium"
                fi
+
+               # Sometimes, when adding a new LLVM slot, devs (me) forget to 
install an appropriate lld.
+               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
+               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
+                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
+               fi
        fi
 
        chromium_suid_sandbox_check_kernel_config

diff --git a/www-client/chromium/chromium-147.0.7703.0-r1.ebuild 
b/www-client/chromium/chromium-147.0.7703.0-r1.ebuild
index ad558338c721..7d249edb16a8 100644
--- a/www-client/chromium/chromium-147.0.7703.0-r1.ebuild
+++ b/www-client/chromium/chromium-147.0.7703.0-r1.ebuild
@@ -91,7 +91,10 @@ SLOT="unstable"
 IUSE_SYSTEM_LIBS="+system-harfbuzz +system-icu +system-zstd"
 IUSE="+X ${IUSE_SYSTEM_LIBS} bindist bundled-toolchain cups debug 
ffmpeg-chromium gtk4 +hangouts headless kerberos +official pax-kernel pgo"
 IUSE+=" +proprietary-codecs pulseaudio qt6 +rar +screencast selinux test 
+vaapi +wayland +widevine cpu_flags_ppc_vsx3"
-RESTRICT="!bindist? ( bindist ) !test? ( test )"
+RESTRICT="
+       !bindist? ( bindist )
+       !test? ( test )
+       arm64? ( test )" # Tests require CFI, which requires LTO, which is 
broken on arm64 with LLVM 21.
 
 REQUIRED_USE="
        !headless? ( || ( X wayland ) )
@@ -318,26 +321,47 @@ pkg_setup() {
                # The pre_build_checks are all about compilation resources, no 
need to run it for a binpkg
                pre_build_checks
 
+               # We haven't massaged any CFLAGS yet, so we want to do this 
before we force CC/CXX to prevent warnings.
+               local want_lto="false"
+               tc-is-lto && want_lto="true"
+
                # The linux:unbundle toolchain in GN grabs CC, CXX, CPP (etc) 
from the environment
                # We'll set these to clang here then use llvm-utils functions 
to very explicitly set these
                # to a sane value.
                # This is effectively the 'force-clang' path if GCC support is 
re-added.
-               # TODO: check if the user has already selected a specific impl 
via make.conf and respect that.
+               if use !bundled-toolchain; then
+                       llvm-r1_pkg_setup
+                       rust_pkg_setup
+
+                       # Forcing clang; respect llvm_slot_x to enable 
selection of impl via LLVM_COMPAT
+                       AR=llvm-ar
+                       CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
+                       NM=llvm-nm
+                       CC="${CHOST}-clang-${LLVM_SLOT}"
+                       CXX="${CHOST}-clang++-${LLVM_SLOT}"
+               fi
+
                use_lto="false"
-               if tc-is-lto; then
-                       use_lto="true"
-                       # We can rely on GN to do this for us; anecdotally 
without this builds
-                       # take significantly longer with LTO enabled and it 
doesn't hurt anything.
+               local lto_usable="true"
+               if [[ "$want_lto" == "true" ]]; then
+                       if use arm64 && [[ "${LLVM_SLOT}" -lt 22 ]]; then
+                               einfo "LTO is broken with LLVM 21 on arm64, 
ignoring CFLAGS."
+                               lto_usable="false"
+                       else
+                               use_lto="true"
+                       fi
+                       # We can rely on GN to do this for us; without this 
builds
+                       # take significantly longer with LTO enabled.
                        filter-lto
                fi
 
-               if [ "$use_lto" = "false" ] && use official; then
+               if [[ "$use_lto" == "false" ]] && use official && [[ 
"$lto_usable" == "true" ]]; then
                        einfo "USE=official selected and LTO not detected."
                        einfo "It is _highly_ recommended that LTO be enabled 
for performance reasons"
                        einfo "and to be consistent with the upstream 
\"official\" build optimisations."
                fi
 
-               if [ "$use_lto" = "false" ] && use test; then
+               if [[ "$use_lto" == "false" ]] && use test; then
                        die "Tests require CFI which requires LTO"
                fi
 
@@ -350,25 +374,6 @@ pkg_setup() {
                        die "Please switch to a different linker."
                fi
 
-               if use !bundled-toolchain; then
-                       llvm-r1_pkg_setup
-                       rust_pkg_setup
-               fi
-
-               # Forcing clang; respect llvm_slot_x to enable selection of 
impl from LLVM_COMPAT
-               AR=llvm-ar
-               CPP="${CHOST}-clang++-${LLVM_SLOT} -E"
-               NM=llvm-nm
-               CC="${CHOST}-clang-${LLVM_SLOT}"
-               CXX="${CHOST}-clang++-${LLVM_SLOT}"
-
-               # Sanity check our linker here; sometimes when adding a new 
LLVM slot devs (me) forget
-               # to install an appropriate lld version. llvm-r1_pkg_setup 
prefixed PATH for us, so it should be there.
-               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
-               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
-                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
-               fi
-
                if tc-is-cross-compiler; then
                        use pgo && die "The pgo USE flag cannot be used when 
cross-compiling"
                        CPP="${CBUILD}-clang++-${LLVM_SLOT} -E"
@@ -378,10 +383,16 @@ pkg_setup() {
                # us poor packagers. Required for Split LTO units, which are 
required for CFI.
                export RUSTC_BOOTSTRAP=1
 
-               # Users should never hit this, it's purely a development 
convenience
+               # Sanity checks for development convenience
                if ver_test $(gn --version || die) -lt ${GN_MIN_VER}; then
                        die "dev-build/gn >= ${GN_MIN_VER} is required to build 
this Chromium"
                fi
+
+               # Sometimes, when adding a new LLVM slot, devs (me) forget to 
install an appropriate lld.
+               local lld_ver=$(ld.lld --version | awk '{split($2,a,"."); print 
a[1]}' || die "Failed to check lld version")
+               if [[ ${lld_ver} -lt ${LLVM_SLOT} ]]; then
+                       die "Your lld version (${lld_ver}) is too old for the 
selected LLVM slot (${LLVM_SLOT}). Please install a newer lld or select an 
older LLVM slot."
+               fi
        fi
 
        chromium_suid_sandbox_check_kernel_config

Reply via email to