[v2,1/4] Makeconfig: Add libgcc directory to rtld-prefix search path
Checks
| Context |
Check |
Description |
| redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
| linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Test passed
|
Commit Message
* This needs to be done twice, for test runs with and without
--enable-hardcoded-path-in-tests
* Also, we need to query the used $(CC) for the library location.
* The container tests run ldd and dump the list of needed libraries, then
copy these into the container.
* Without this patch, ldd may not find libgcc_s.so, resulting in"not found"
output and no copying of the library.
* With this patch, the library is picked up independent of its location (as
long as the proper directory is provided) and copied into the testroot.
* This does not mean yet that ld.so in the testroot actually finds it.
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
---
Makeconfig | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
Comments
On 08/02/25 13:09, Andreas K. Hüttel wrote:
> * This needs to be done twice, for test runs with and without
> --enable-hardcoded-path-in-tests
> * Also, we need to query the used $(CC) for the library location.
>
> * The container tests run ldd and dump the list of needed libraries, then
> copy these into the container.
> * Without this patch, ldd may not find libgcc_s.so, resulting in"not found"
> output and no copying of the library.
> * With this patch, the library is picked up independent of its location (as
> long as the proper directory is provided) and copied into the testroot.
>
> * This does not mean yet that ld.so in the testroot actually finds it.
>
> Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
> ---
> Makeconfig | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/Makeconfig b/Makeconfig
> index d0108d2caa..0820f860b2 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -635,7 +635,7 @@ link-libc-printers-tests = $(link-libc-rpath) \
> # This is how to find at build-time things that will be installed there.
> rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
> rpath-link = \
> -$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
> +$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))):$(gnulib-extralibdir)
> else # build-static
> link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
> link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
> @@ -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.
> #
> # 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 dirname $$($(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version)))
This does not return a workable path on a Ubuntu installation, it seems
that the internal $(libgcc_s.so-version) is not evaluated correctly:
$ arm-linux-gnueabihf-gcc -print-file-name=libgcc_s.so.1
/usr/lib/gcc-cross/arm-linux-gnueabihf/13/../../../../arm-linux-gnueabihf/lib/libgcc_s.so.1
But I am seeing '/usr/lib/gcc-cross/arm-linux-gnueabihf/13' which is
-print-file-name for 'libgcc_s.so.1'.
The:
gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
evaluates to a correct path. With this change I only see a failure,
and only without --enable-hardcoded-path-in-tests:
FAIL: elf/tst-pathopt
Because the test issues the loader through a shell script without
the $(gnulib-extralibdir). The following change fixes it:
diff --git a/elf/Makefile b/elf/Makefile
index 1ea0e7037e..f0c4bed8ce 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -1869,7 +1869,7 @@ $(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
$(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
$(objpfx)pathoptobj.so
$(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
- '$(run-program-env)'; \
+ '$(run-program-env)' '$(gnulib-extralibdir)'; \
$(evaluate-test)
$(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
diff --git a/elf/tst-pathopt.sh b/elf/tst-pathopt.sh
index b1539c8ee9..e5b124ea65 100755
--- a/elf/tst-pathopt.sh
+++ b/elf/tst-pathopt.sh
@@ -22,6 +22,7 @@ set -e
common_objpfx=$1
test_wrapper_env=$2
run_program_env=$3
+gnulib_extralibdir=$4
test -e ${common_objpfx}elf/will-be-empty &&
rm -fr ${common_objpfx}elf/will-be-empty
@@ -32,7 +33,7 @@ cp ${common_objpfx}elf/pathoptobj.so ${common_objpfx}elf/for-renamed/renamed.so
${test_wrapper_env} \
${run_program_env} \
-LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn \
+LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn:${gnulib_extralibdir} \
${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-pathopt \
> ${common_objpfx}elf/tst-pathopt.out
> static-gnulib-arch =
> # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
> # statically link programs. When --disable-shared is used, we use
> @@ -781,10 +787,12 @@ endif
>
> # How to run a program we just linked with our library.
> # The program binary is assumed to be $(word 2,$^).
> +# We may require additional libraries from gcc (e.g. libgcc_s.so for exception
> +# handling), which unfortunately somewhat breaks the isolation.
> built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
> rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
> --library-path \
> - $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
> + $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)):$(gnulib-extralibdir)
> ifeq (yes,$(build-shared))
> comma = ,
> sysdep-library-path = \
On Tue, Feb 25, 2025 at 10:43 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 08/02/25 13:09, Andreas K. Hüttel wrote:
> > * This needs to be done twice, for test runs with and without
> > --enable-hardcoded-path-in-tests
> > * Also, we need to query the used $(CC) for the library location.
> >
> > * The container tests run ldd and dump the list of needed libraries, then
> > copy these into the container.
> > * Without this patch, ldd may not find libgcc_s.so, resulting in"not found"
> > output and no copying of the library.
> > * With this patch, the library is picked up independent of its location (as
> > long as the proper directory is provided) and copied into the testroot.
> >
> > * This does not mean yet that ld.so in the testroot actually finds it.
> >
> > Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
> > ---
> > Makeconfig | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/Makeconfig b/Makeconfig
> > index d0108d2caa..0820f860b2 100644
> > --- a/Makeconfig
> > +++ b/Makeconfig
> > @@ -635,7 +635,7 @@ link-libc-printers-tests = $(link-libc-rpath) \
> > # This is how to find at build-time things that will be installed there.
> > rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
> > rpath-link = \
> > -$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
> > +$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))):$(gnulib-extralibdir)
> > else # build-static
> > link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
> > link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
> > @@ -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.
> > #
> > # 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 dirname $$($(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version)))
>
> This does not return a workable path on a Ubuntu installation, it seems
> that the internal $(libgcc_s.so-version) is not evaluated correctly:
>
> $ arm-linux-gnueabihf-gcc -print-file-name=libgcc_s.so.1
> /usr/lib/gcc-cross/arm-linux-gnueabihf/13/../../../../arm-linux-gnueabihf/lib/libgcc_s.so.1
>
> But I am seeing '/usr/lib/gcc-cross/arm-linux-gnueabihf/13' which is
> -print-file-name for 'libgcc_s.so.1'.
>
> The:
>
> gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
Though this looks like it is causing some issues with some shells. The
`##` causes the reset of the line to be ignored and I get the
following error message:
../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
Thanks,
Andrew Pinski
>
> evaluates to a correct path. With this change I only see a failure,
> and only without --enable-hardcoded-path-in-tests:
>
> FAIL: elf/tst-pathopt
>
> Because the test issues the loader through a shell script without
> the $(gnulib-extralibdir). The following change fixes it:
>
> diff --git a/elf/Makefile b/elf/Makefile
> index 1ea0e7037e..f0c4bed8ce 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -1869,7 +1869,7 @@ $(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
> $(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
> $(objpfx)pathoptobj.so
> $(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
> - '$(run-program-env)'; \
> + '$(run-program-env)' '$(gnulib-extralibdir)'; \
> $(evaluate-test)
>
> $(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
> diff --git a/elf/tst-pathopt.sh b/elf/tst-pathopt.sh
> index b1539c8ee9..e5b124ea65 100755
> --- a/elf/tst-pathopt.sh
> +++ b/elf/tst-pathopt.sh
> @@ -22,6 +22,7 @@ set -e
> common_objpfx=$1
> test_wrapper_env=$2
> run_program_env=$3
> +gnulib_extralibdir=$4
>
> test -e ${common_objpfx}elf/will-be-empty &&
> rm -fr ${common_objpfx}elf/will-be-empty
> @@ -32,7 +33,7 @@ cp ${common_objpfx}elf/pathoptobj.so ${common_objpfx}elf/for-renamed/renamed.so
>
> ${test_wrapper_env} \
> ${run_program_env} \
> -LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn \
> +LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn:${gnulib_extralibdir} \
> ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-pathopt \
> > ${common_objpfx}elf/tst-pathopt.out
>
>
> > static-gnulib-arch =
> > # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
> > # statically link programs. When --disable-shared is used, we use
> > @@ -781,10 +787,12 @@ endif
> >
> > # How to run a program we just linked with our library.
> > # The program binary is assumed to be $(word 2,$^).
> > +# We may require additional libraries from gcc (e.g. libgcc_s.so for exception
> > +# handling), which unfortunately somewhat breaks the isolation.
> > built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
> > rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
> > --library-path \
> > - $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
> > + $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)):$(gnulib-extralibdir)
> > ifeq (yes,$(build-shared))
> > comma = ,
> > sysdep-library-path = \
>
On Mon, 2025-07-21 at 07:34 -0700, Andrew Pinski wrote:
> > gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
>
> Though this looks like it is causing some issues with some shells. The
> `##` causes the reset of the line to be ignored and I get the
> following error message:
> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
I'd say it's some versions of make instead of some shells, as it fails
even before getting into the shell.
On Jul 21 2025, Xi Ruoyao wrote:
> On Mon, 2025-07-21 at 07:34 -0700, Andrew Pinski wrote:
>> > gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
>>
>> Though this looks like it is causing some issues with some shells. The
>> `##` causes the reset of the line to be ignored and I get the
>> following error message:
>> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
>
> I'd say it's some versions of make instead of some shells, as it fails
> even before getting into the shell.
From the NEWS of GNU make 4.3:
* WARNING: Backward-incompatibility!
Number signs (#) appearing inside a macro reference or function invocation
no longer introduce comments and should not be escaped with backslashes:
thus a call such as:
foo := $(shell echo '#')
is legal. Previously the number sign needed to be escaped, for example:
foo := $(shell echo '\#')
Now this latter will resolve to "\#". If you want to write makefiles
portable to both versions, assign the number sign to a variable:
H := \#
foo := $(shell echo '$H')
This was claimed to be fixed in 3.81, but wasn't, for some reason.
To detect this change search for 'nocomment' in the .FEATURES variable.
On Mon, Jul 21, 2025 at 8:27 AM Andreas Schwab <schwab@suse.de> wrote:
>
> On Jul 21 2025, Xi Ruoyao wrote:
>
> > On Mon, 2025-07-21 at 07:34 -0700, Andrew Pinski wrote:
> >> > gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
> >>
> >> Though this looks like it is causing some issues with some shells. The
> >> `##` causes the reset of the line to be ignored and I get the
> >> following error message:
> >> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
> >
> > I'd say it's some versions of make instead of some shells, as it fails
> > even before getting into the shell.
>
> From the NEWS of GNU make 4.3:
So make 4.3 is fixed but glibc officially only requires 4.0+. Do we
change the requirement or workaround older makes?
Thanks,
Andrew
>
> * WARNING: Backward-incompatibility!
> Number signs (#) appearing inside a macro reference or function invocation
> no longer introduce comments and should not be escaped with backslashes:
> thus a call such as:
> foo := $(shell echo '#')
> is legal. Previously the number sign needed to be escaped, for example:
> foo := $(shell echo '\#')
> Now this latter will resolve to "\#". If you want to write makefiles
> portable to both versions, assign the number sign to a variable:
> H := \#
> foo := $(shell echo '$H')
> This was claimed to be fixed in 3.81, but wasn't, for some reason.
> To detect this change search for 'nocomment' in the .FEATURES variable.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
On 21/07/25 12:39, Andrew Pinski wrote:
> On Mon, Jul 21, 2025 at 8:27 AM Andreas Schwab <schwab@suse.de> wrote:
>>
>> On Jul 21 2025, Xi Ruoyao wrote:
>>
>>> On Mon, 2025-07-21 at 07:34 -0700, Andrew Pinski wrote:
>>>>> gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
>>>>
>>>> Though this looks like it is causing some issues with some shells. The
>>>> `##` causes the reset of the line to be ignored and I get the
>>>> following error message:
>>>> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
>>>
>>> I'd say it's some versions of make instead of some shells, as it fails
>>> even before getting into the shell.
>>
>> From the NEWS of GNU make 4.3:
>
> So make 4.3 is fixed but glibc officially only requires 4.0+. Do we
> change the requirement or workaround older makes?
>
I would prefer to latter, do we have an easy workaround for this?
> Thanks,
> Andrew
>
>
>>
>> * WARNING: Backward-incompatibility!
>> Number signs (#) appearing inside a macro reference or function invocation
>> no longer introduce comments and should not be escaped with backslashes:
>> thus a call such as:
>> foo := $(shell echo '#')
>> is legal. Previously the number sign needed to be escaped, for example:
>> foo := $(shell echo '\#')
>> Now this latter will resolve to "\#". If you want to write makefiles
>> portable to both versions, assign the number sign to a variable:
>> H := \#
>> foo := $(shell echo '$H')
>> This was claimed to be fixed in 3.81, but wasn't, for some reason.
>> To detect this change search for 'nocomment' in the .FEATURES variable.
>>
>> --
>> Andreas Schwab, SUSE Labs, schwab@suse.de
>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
>> "And now for something completely different."
* Andrew Pinski:
> On Mon, Jul 21, 2025 at 8:27 AM Andreas Schwab <schwab@suse.de> wrote:
>>
>> On Jul 21 2025, Xi Ruoyao wrote:
>>
>> > On Mon, 2025-07-21 at 07:34 -0700, Andrew Pinski wrote:
>> >> > gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
>> >>
>> >> Though this looks like it is causing some issues with some shells. The
>> >> `##` causes the reset of the line to be ignored and I get the
>> >> following error message:
>> >> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
>> >
>> > I'd say it's some versions of make instead of some shells, as it fails
>> > even before getting into the shell.
>>
>> From the NEWS of GNU make 4.3:
>
> So make 4.3 is fixed but glibc officially only requires 4.0+. Do we
> change the requirement or workaround older makes?
Isn't this just dirname? Can't we use that instead? Not sure if I'd
call this a workaround. 8-)
Thanks,
Florian
> > > @@ -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 dirname $$($(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version)))
> >
> > This does not return a workable path on a Ubuntu installation, it seems
> > that the internal $(libgcc_s.so-version) is not evaluated correctly:
> >
> > $ arm-linux-gnueabihf-gcc -print-file-name=libgcc_s.so.1
> > /usr/lib/gcc-cross/arm-linux-gnueabihf/13/../../../../arm-linux-gnueabihf/lib/libgcc_s.so.1
> >
> > But I am seeing '/usr/lib/gcc-cross/arm-linux-gnueabihf/13' which is
> > -print-file-name for 'libgcc_s.so.1'.
> >
> > The:
> >
> > gnulib-extralibdir = $(shell $(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version) | sed 's#/[^/]*$$##')
>
> Though this looks like it is causing some issues with some shells. The
> `##` causes the reset of the line to be ignored and I get the
> following error message:
> ../Makeconfig:721: *** unterminated call to function 'shell': missing ')'. Stop.
>
Eh, if picking # as the separator in the sed s command is a problem, the easiest solution is
to just pick another character that make does not treat special, e.g., maybe this?
sed 's_/[^/]*$$__'
(After verifying that the command line does what we need, I didn't bother digging into what
the problem with the original dirname was.)
>
> Thanks,
> Andrew Pinski
>
>
> >
> > evaluates to a correct path. With this change I only see a failure,
> > and only without --enable-hardcoded-path-in-tests:
> >
> > FAIL: elf/tst-pathopt
> >
> > Because the test issues the loader through a shell script without
> > the $(gnulib-extralibdir). The following change fixes it:
> >
> > diff --git a/elf/Makefile b/elf/Makefile
> > index 1ea0e7037e..f0c4bed8ce 100644
> > --- a/elf/Makefile
> > +++ b/elf/Makefile
> > @@ -1869,7 +1869,7 @@ $(objpfx)lateglobal.out: $(objpfx)ltglobmod1.so $(objpfx)ltglobmod2.so
> > $(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
> > $(objpfx)pathoptobj.so
> > $(SHELL) $< $(common-objpfx) '$(test-wrapper-env)' \
> > - '$(run-program-env)'; \
> > + '$(run-program-env)' '$(gnulib-extralibdir)'; \
> > $(evaluate-test)
> >
> > $(objpfx)tst-rtld-load-self.out: tst-rtld-load-self.sh $(objpfx)ld.so
> > diff --git a/elf/tst-pathopt.sh b/elf/tst-pathopt.sh
> > index b1539c8ee9..e5b124ea65 100755
> > --- a/elf/tst-pathopt.sh
> > +++ b/elf/tst-pathopt.sh
> > @@ -22,6 +22,7 @@ set -e
> > common_objpfx=$1
> > test_wrapper_env=$2
> > run_program_env=$3
> > +gnulib_extralibdir=$4
> >
> > test -e ${common_objpfx}elf/will-be-empty &&
> > rm -fr ${common_objpfx}elf/will-be-empty
> > @@ -32,7 +33,7 @@ cp ${common_objpfx}elf/pathoptobj.so ${common_objpfx}elf/for-renamed/renamed.so
> >
> > ${test_wrapper_env} \
> > ${run_program_env} \
> > -LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn \
> > +LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn:${gnulib_extralibdir} \
> > ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-pathopt \
> > > ${common_objpfx}elf/tst-pathopt.out
> >
> >
> > > static-gnulib-arch =
> > > # By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
> > > # statically link programs. When --disable-shared is used, we use
> > > @@ -781,10 +787,12 @@ endif
> > >
> > > # How to run a program we just linked with our library.
> > > # The program binary is assumed to be $(word 2,$^).
> > > +# We may require additional libraries from gcc (e.g. libgcc_s.so for exception
> > > +# handling), which unfortunately somewhat breaks the isolation.
> > > built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
> > > rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
> > > --library-path \
> > > - $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
> > > + $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)):$(gnulib-extralibdir)
> > > ifeq (yes,$(build-shared))
> > > comma = ,
> > > sysdep-library-path = \
> >
>
@@ -635,7 +635,7 @@ link-libc-printers-tests = $(link-libc-rpath) \
# This is how to find at build-time things that will be installed there.
rpath-dirs = math elf dlfcn nss nis rt resolv mathvec support
rpath-link = \
-$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%)))
+$(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))):$(gnulib-extralibdir)
else # build-static
link-libc = $(common-objpfx)libc.a $(otherlibs) $(gnulib) $(common-objpfx)libc.a $(gnulib)
link-libc-tests = $(common-objpfx)libc.a $(otherlibs) $(gnulib-tests) $(common-objpfx)libc.a $(gnulib-tests)
@@ -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.
#
# 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 dirname $$($(CC) -print-file-name=libgcc_s.so$(libgcc_s.so-version)))
static-gnulib-arch =
# By default, elf/static-stubs.o, instead of -lgcc_eh, is used to
# statically link programs. When --disable-shared is used, we use
@@ -781,10 +787,12 @@ endif
# How to run a program we just linked with our library.
# The program binary is assumed to be $(word 2,$^).
+# We may require additional libraries from gcc (e.g. libgcc_s.so for exception
+# handling), which unfortunately somewhat breaks the isolation.
built-program-file = $(dir $(word 2,$^))$(notdir $(word 2,$^))
rtld-prefix = $(elf-objpfx)$(rtld-installed-name) \
--library-path \
- $(rpath-link)$(patsubst %,:%,$(sysdep-library-path))
+ $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)):$(gnulib-extralibdir)
ifeq (yes,$(build-shared))
comma = ,
sysdep-library-path = \