commit:     e6dc7912a8a81c9f25f6b550df2d5e52b5119398
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 07:22:22 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Dec 29 07:29:59 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e6dc7912

dev-libs/glib: do a proper install for the bootstrap gobject-introspection

In a fresh musl stage3, I could reproduce the reported "can't resolve libraries 
to shared libraries: m"
error. In another, older musl chroot, it worked fine.

The difference in the g-ir-scanner invocations between the two was
the good build had `--extra-library=m` and friends, while the bad one used
raw `-lm`. meson's `_gir_has_option` invokes `g-ir-scanner --help` to see
if it supports `--extra-library` or not.

The check was failing with:
 ImportError: Error loading shared library libglib-2.0.so.0: No such file or 
directory (needed by .../scanner.cpython-312-x86_64-linux-musl.so)
because RPATH didn't reflect what we were trying to do.

By using --prefix=${EPREFIX}/usr (the default) with --destdir ${T} and
--skip-subprojects glib, we were having to pray that running everything
with LD_LIBRARY_PATH & friends set would work out, rather than installing
it properly to ${T} and letting RPATH do its job. We now let Meson install
glib and gobject-introspection properly to ${T}/bootstrap-gi-prefix and
tell everything where to find it.

As for why it didn't show up earlier in glibc stage3s w/o glib already 
installed:
musl doesn't have libm.so, it does have a stub libm.a. glibc has a stub libm.so
nowadays as it merged everything in to libc.so.

I haven't cleaned up all the previous workarounds and hacks which may
no longer be needed in case we need to do more meddling here.

Thanks to Eli for both letting me rubberduck and also giving critical
suggestions that made the problem (and solution) obvious.

Closes: https://bugs.gentoo.org/945911
Thanks-to: Eli Schwartz <eschwartz <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/glib/glib-2.80.5-r1.ebuild | 17 +++++++++++------
 dev-libs/glib/glib-2.82.4-r1.ebuild | 17 +++++++++++------
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/dev-libs/glib/glib-2.80.5-r1.ebuild 
b/dev-libs/glib/glib-2.80.5-r1.ebuild
index cdc1222f8c58..5cd0b2716ca0 100644
--- a/dev-libs/glib/glib-2.80.5-r1.ebuild
+++ b/dev-libs/glib/glib-2.80.5-r1.ebuild
@@ -223,18 +223,21 @@ multilib_src_configure() {
                #esac
        #fi
 
-       # Build internal copy of gobject-introspection to avoid circular 
dependency (Built for native abi only)
+       # Build internal copy of gobject-introspection to avoid circular 
dependency (built for native abi only)
        if multilib_native_use introspection && ! has_version 
">=dev-libs/${INTROSPECTION_P}" ; then
                einfo "Bootstrapping gobject-introspection..."
-               INTROSPECTION_BIN_DIR="${T}/${EPREFIX}/usr/bin"
-               INTROSPECTION_LIB_DIR="${T}/${EPREFIX}/usr/$(get_libdir)"
+               INTROSPECTION_BIN_DIR="${T}/bootstrap-gi-prefix/usr/bin"
+               
INTROSPECTION_LIB_DIR="${T}/bootstrap-gi-prefix/usr/$(get_libdir)"
 
                local emesonargs=(
+                       --prefix="${T}/bootstrap-gi-prefix/usr"
                        -Dpython="${EPYTHON}"
                        -Dbuild_introspection_data=true
                        # Build an internal copy of glib for the internal copy 
of gobject-introspection
                        --force-fallback-for=glib
-                       # Tell meson to make paths in pkgconfig files relative, 
because we arent doing an actual install
+                       # Make the paths in pkgconfig files relative as we used 
to not
+                       # do a proper install here and it seems less risky to 
keep it
+                       # this way.
                        -Dpkgconfig.relocatable=true
 
                        # We want as minimal a build as possible here to speed 
things up
@@ -270,8 +273,10 @@ multilib_src_configure() {
 
                meson_src_configure
                meson_src_compile
-               # Install to the portage temp directory so that pkgconfig 
relative paths resolve correctly
-               meson_src_install --destdir "${T}" --skip-subprojects glib
+               # We already provide a prefix in ${T} above. Blank DESTDIR
+               # as it may be set in the environment by Portage (though not
+               # guaranteed in src_configure).
+               meson_src_install --destdir ""
 
                popd || die
 

diff --git a/dev-libs/glib/glib-2.82.4-r1.ebuild 
b/dev-libs/glib/glib-2.82.4-r1.ebuild
index 4c84301e4ef8..9cb47e594084 100644
--- a/dev-libs/glib/glib-2.82.4-r1.ebuild
+++ b/dev-libs/glib/glib-2.82.4-r1.ebuild
@@ -211,18 +211,21 @@ multilib_src_configure() {
                #esac
        #fi
 
-       # Build internal copy of gobject-introspection to avoid circular 
dependency (Built for native abi only)
+       # Build internal copy of gobject-introspection to avoid circular 
dependency (built for native abi only)
        if multilib_native_use introspection && ! has_version 
">=dev-libs/${INTROSPECTION_P}" ; then
                einfo "Bootstrapping gobject-introspection..."
-               INTROSPECTION_BIN_DIR="${T}/${EPREFIX}/usr/bin"
-               INTROSPECTION_LIB_DIR="${T}/${EPREFIX}/usr/$(get_libdir)"
+               INTROSPECTION_BIN_DIR="${T}/bootstrap-gi-prefix/usr/bin"
+               
INTROSPECTION_LIB_DIR="${T}/bootstrap-gi-prefix/usr/$(get_libdir)"
 
                local emesonargs=(
+                       --prefix="${T}/bootstrap-gi-prefix/usr"
                        -Dpython="${EPYTHON}"
                        -Dbuild_introspection_data=true
                        # Build an internal copy of glib for the internal copy 
of gobject-introspection
                        --force-fallback-for=glib
-                       # Tell meson to make paths in pkgconfig files relative, 
because we arent doing an actual install
+                       # Make the paths in pkgconfig files relative as we used 
to not
+                       # do a proper install here and it seems less risky to 
keep it
+                       # this way.
                        -Dpkgconfig.relocatable=true
 
                        # We want as minimal a build as possible here to speed 
things up
@@ -258,8 +261,10 @@ multilib_src_configure() {
 
                meson_src_configure
                meson_src_compile
-               # Install to the portage temp directory so that pkgconfig 
relative paths resolve correctly
-               meson_src_install --destdir "${T}" --skip-subprojects glib
+               # We already provide a prefix in ${T} above. Blank DESTDIR
+               # as it may be set in the environment by Portage (though not
+               # guaranteed in src_configure).
+               meson_src_install --destdir ""
 
                popd || die
 

Reply via email to