commit:     6e7857db57a841f28066459ece787800f2a28f2a
Author:     Matt Jolly <kangie <AT> gentoo <DOT> org>
AuthorDate: Mon Sep 30 06:53:09 2024 +0000
Commit:     Matt Jolly <kangie <AT> gentoo <DOT> org>
CommitDate: Mon Sep 30 06:54:11 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e7857db

www-client/chromium: `die` if rust profiler not found

Chromium's build system explicitly looks for
`libprofiler_builtins-*.rlib` when using a prebuilt / system Rust.

While we could patch this out so that users don't _need_
USE=profiler if not doing PGO, the Rust upstream default is to ship
the profiler; conditionally changing the Chromium build logic to
account for an untested and unsupported build is not desirable.

Instead we will rely on existing dependency checks
(which ensure that a Rust slot with the profiler is installed)
and do a sanity check on the selected Rust implementation before
unpacking Chromium's enormous tarball so that we can fail early and
prompt the user to `eselect` the correct version / slot.

Closes: https://bugs.gentoo.org/937161
Signed-off-by: Matt Jolly <kangie <AT> gentoo.org>

 www-client/chromium/chromium-129.0.6668.70.ebuild | 14 ++++++++++++++
 www-client/chromium/chromium-130.0.6723.19.ebuild | 14 ++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/www-client/chromium/chromium-129.0.6668.70.ebuild 
b/www-client/chromium/chromium-129.0.6668.70.ebuild
index 16059a00a6bc..23624456867c 100644
--- a/www-client/chromium/chromium-129.0.6668.70.ebuild
+++ b/www-client/chromium/chromium-129.0.6668.70.ebuild
@@ -416,7 +416,21 @@ pkg_setup() {
                                        einfo "Using rust ${rustc_ver} to build"
                        fi
 
+                       # Chromium requires the Rust profiler library while 
setting up its build environment.
+                       # Since a standard Rust comes with the profiler, 
instead of patching it out (build/rust/std/BUILD.gn#L103)
+                       # we'll just do a sanity check on the selected slot.
+                       if [[ "$(eselect --brief rust show 2>/dev/null)" != 
*"bin"* ]]; then
+                               local arch=$(uname -m)
+                               local 
rust_lib_path="${EPREFIX}/usr/lib/rust/${rustc_ver}/lib/rustlib/${arch}-unknown-linux-gnu/lib"
+                               local profiler_lib=$(find "${rust_lib_path}" 
-name "libprofiler_builtins-*.rlib" -print -quit)
+                               if [[ -z "${profiler_lib}" ]]; then
+                                       eerror "Rust ${rustc_ver} is missing 
the profiler library."
+                                       eerror "ebuild dependency resolution 
should have ensured that a Rust with the profiler was installed."
+                                       die "Please \`eselect\` a Rust slot 
that has the profiler."
+                               fi
+                       fi
                fi
+
                # Users should never hit this, it's purely a 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"

diff --git a/www-client/chromium/chromium-130.0.6723.19.ebuild 
b/www-client/chromium/chromium-130.0.6723.19.ebuild
index 1f07aceefef6..4247ea726933 100644
--- a/www-client/chromium/chromium-130.0.6723.19.ebuild
+++ b/www-client/chromium/chromium-130.0.6723.19.ebuild
@@ -416,7 +416,21 @@ pkg_setup() {
                                        einfo "Using rust ${rustc_ver} to build"
                        fi
 
+                       # Chromium requires the Rust profiler library while 
setting up its build environment.
+                       # Since a standard Rust comes with the profiler, 
instead of patching it out (build/rust/std/BUILD.gn#L103)
+                       # we'll just do a sanity check on the selected slot.
+                       if [[ "$(eselect --brief rust show 2>/dev/null)" != 
*"bin"* ]]; then
+                               local arch=$(uname -m)
+                               local 
rust_lib_path="${EPREFIX}/usr/lib/rust/${rustc_ver}/lib/rustlib/${arch}-unknown-linux-gnu/lib"
+                               local profiler_lib=$(find "${rust_lib_path}" 
-name "libprofiler_builtins-*.rlib" -print -quit)
+                               if [[ -z "${profiler_lib}" ]]; then
+                                       eerror "Rust ${rustc_ver} is missing 
the profiler library."
+                                       eerror "ebuild dependency resolution 
should have ensured that a Rust with the profiler was installed."
+                                       die "Please \`eselect\` a Rust slot 
that has the profiler."
+                               fi
+                       fi
                fi
+
                # Users should never hit this, it's purely a 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"

Reply via email to