[PATCH 1/4] Makeconfig: Add libgcc directory to rtld-prefix search path
Andreas K. Huettel
dilfridge@gentoo.org
Thu Jan 30 16:59:39 GMT 2025
Am Donnerstag, 30. Januar 2025, 17:26:30 Mitteleuropäische Normalzeit schrieb Adhemerval Zanella Netto:
>
> On 30/01/25 10:33, Florian Weimer wrote:
> > * Adhemerval Zanella Netto:
> >
> >>> Not only that. On many architectures, libgcc_s.so is a linker script in
> >>> the same directory as libgcc.a.
> >>>
> >>> If we want to automatically follow what ldconfig does, I think we should
> >>> teach ldconfig to print the information we need. Then this gets solved
> >>> after a couple of releases.
> >>
> >> I think this does not solve if you use a non-default compiler that has its
> >> own libgcc_s.so, for instance if you build it with bmg. For the issue of
> >> the extra libgcc_s.so dependency, I see the most straightforward fix just
> >> to copy it on the builddir (maybe along with libstdc++.so so tests will
> >> also use the library g++ linked against).
> >
> > If we want to copy the file, we should use
> >
> > -print-file-name=libgcc_s.so.$(libgcc_s-version)
> >
> > where $(libgcc_s-version) comes form shlib-versions (see
> > sysdeps/hppa/shlib-versions for an example). This way, we get the real
> > object, and not the linker script.
>
>
> We can also use '-print-file-name=libgcc_s.so.$(libgcc_s-version)' with
> the original approach to add in on either the --library-path or RPATH.
>
> I think we will need add a bit more machinery to handle the container
> tests (since we will need an extra copy rule to handle non system
> libraries).
Actually this patch series was for (and works with) the container tests.
The trick is the following:
* Patch 1/4 adds the directory where libgcc_s.so is to the search path of
the loader invocation used in the test suite.
* The container tests work as follows, they run ldd and dump the list of
needed libraries, then copy these into the container.
* Without 1/4, ldd does not find libgcc_s.so, resulting in some "not found"
output and no copying of the library.
* With 1/4, the library is picked up independent of its location (as long
as the directory is provided) and copied into the testroot.
So extra logic for copying the library is not needed as long as we tell
ldd where it can search (via the ld.so --libdir).
Since the container technique replicates the paths of the main system,
patches 2/4 and 3/4 ensure the library is also found in the container then
(its location may not be in the ld.so default search path there).
>
> >
> > I think this should workk in a Makefile:
> >
> > libgcc_s-version = $(shell $(AWK) -F= '/^libgcc_s=/{print $2}' < $(common-objpfx)shlib-versions.v)
> >
> > Not sure if there's a nicer way to get that version.
> >
> > Thanks,
> > Florian
> >
>
>
--
Andreas K. Hüttel
dilfridge@gentoo.org
Gentoo Linux developer
(council, comrel, toolchain, base-system, perl, libreoffice)
https://wiki.gentoo.org/wiki/User:Dilfridge
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250130/b5bebe2c/attachment.sig>
More information about the Libc-alpha
mailing list