[PATCH 1/4] Makeconfig: Add libgcc directory to rtld-prefix search path
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jan 30 13:06:20 GMT 2025
On 30/01/25 03:12, Florian Weimer wrote:
> * Adhemerval Zanella Netto:
>
>> On 22/01/25 13:12, dilfridge@gentoo.org wrote:
>>> From: Andreas K. Hüttel <dilfridge@gentoo.org>
>>>
>>> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
>>> ---
>>> Makeconfig | 10 +++++++++-
>>> 1 file changed, 9 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/Makeconfig b/Makeconfig
>>> index d0108d2caa..6b4ebd1320 100644
>>> --- a/Makeconfig
>>> +++ b/Makeconfig
>>> @@ -692,6 +692,11 @@ link-libc-static-tests = -Wl,--start-group $(common-objpfx)libc.a $(static-gnuli
>>> # some cases and it is preferable to link with libgcc_eh or libgcc_s
>>> # so that the testing is as similar as possible to how programs will
>>> # be built with the installed glibc.
>>> +# This leads to moderate difficulties, also since distributions may
>>> +# install libgcc_s.so in directories only found via ld.so.conf, e.g.
>>> +# to be able to switch between gcc versions. We need to add the
>>> +# corresponding directory to the library search path to make sure
>>> +# our test programs can find it.
>
> This also happens when configuring (accidentally or deliberately)
> without --prefix=/usr, so we should really fix that case.
>
>>> # Some architectures have architecture-specific systems for exception
>>> # handling that may involve undefined references to
>>> @@ -709,6 +714,7 @@ libgcc_eh := -Wl,--as-needed -lgcc_s $(libunwind) -Wl,--no-as-needed
>>> gnulib-arch =
>>> gnulib = -lgcc $(gnulib-arch)
>>> gnulib-tests := -lgcc $(libgcc_eh)
>>> +gnulib-extralibdir := $(shell $(CC) -print-libgcc-file-name | sed -e 's:/libgcc.*$$::')
>>
>> From gcc documentation [1], -print-libgcc-file-name is the same as
>> -print-file-name=libgcc.a which might be different than the place
>> libgcc_s.so is installed.
>
> 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).
More information about the Libc-alpha
mailing list