This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [patch] Fix test suite failures with --as-needed
On 24/04/12 11:38, Carlos O'Donell wrote:
> On Mon, Apr 23, 2012 at 8:50 PM, Allan McRae <allan@archlinux.org> wrote:
>>> I have been building glibc (and the rest of the toolchain) for Arch
>>> Linux with --as-needed for a couple of years now and testsuite failures
>>> like these are the only issues I have noticed.
>
> I think this patch is great. Thanks for the work Allan!
>
> Two issues.
>
> (1) The ChangeLog is a *little* terse for my tastes. I like it to be
> sufficiently verbose to be helpful in identifying which functions,
> structures, or in this case Makefile variables have been set or
> changed. See below for examples.
ChangeLog:
2012-04-16 Allan McRae <allan@archlinux.org>
* elf/Makefile: (LDFLAGS-nodel2mod3.so: Use $(no-as-needed).
(LDFLAGS-reldepmod5.so): Likewise.
(LDFLAGS-reldep6mod1.so): Likewise.
(LDFLAGS-reldep6mod4.so): Likewise.
(LDFLAGS-reldep8mod3.so): Likewise.
(LDFLAGS-unload4mod1.so): Likewise.
(LDFLAGS-unload4mod2.so): Likewise.
(LDFLAGS-tst-initorder): Likewise.
(LDFLAGS-tst-initordera2.so): Likewise.
(LDFLAGS-tst-initordera3.so): Likewise.
(LDFLAGS-tst-initordera4.so): Likewise.
(LDFLAGS-tst-initorderb2.so): Likewise.
(LDFLAGS-noload): Likewise.
(LDFLAGS-next): Likewise.
(LDFLAGS-order2mod1.so): Likewise.
(LDFLAGS-order2mod2.so): Likewise.
(LDFLAGS-tst-initorder2): Likewise.
(LDFLAGS-tst-initorder2a.so): Likewise.
(LDFLAGS-tst-initorder2b.so): Likewise.
(LDFLAGS-tst-initorder2c.so): Likewise.
* stdlib/Makefile: (LDFLAGS-tst-putenv): Likewise.
nptl/ChangeLog:
2012-04-16 Allan McRae <allan@archlinux.org>
* Makefile: (LDFLAGS-tst-tls5): Use $(no-as-needed).
(LDFLAGS-tst-cancel24): Likewise.
> (2) You don't present an analysis of *why* the tests fail with
> --as-needed just that the hammer of $(no-as-needed) fixes it. Some of
> the tests clearly failed to compile e.g. Error 1, while others failed
> at runtime. Why? I think you need to provide *some* analysis of the
> failures to show that your fix is correct.
>
Here is a description of three of the fixes showing three observed cases.
1) build failure due to underlinking
2) the test binary itself underlinking
3) the library used by the test underlinking
#1)
make[2]: *** [/build/src/glibc-build/nptl/tst-cancel24] Error 1
>From the testsuite build output:
/build/src/glibc-build/nptl/tst-cancel24.o: In function `tf(void*)':
tst-cancel24.cc:(.text+0x2d): undefined reference to `__cxa_begin_catch'
tst-cancel24.cc:(.text+0x39): undefined reference to `__cxa_rethrow'
tst-cancel24.cc:(.text+0x40): undefined reference to `__cxa_end_catch'
/build/src/glibc-build/nptl/tst-cancel24.o:(.eh_frame+0x13): undefined
reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status
That indicates that tst-cancel24 should be linking to libstdc++ and it
does when built without --as-needed.
In nptl/Makefile there is:
LDFLAGS-tst-cancel24 = -lstdc++
nptl/tst-cancel24.cc is built with g++ but linked using gcc, hence the
need to specify libstdc++. Adding $(no-as-needed) forces the linking of
libstdc++.
#2)
make[2]: *** [/build/src/glibc-build/stdlib/tst-putenv.out] Error 1
In tst-putenv.out with --as-needed "envvar not defined"
With --as-needed:
> readelf -d build/src/glibc-build/stdlib/tst-putenv | grep NEEDED
0x00000001 (NEEDED) Shared library: [libc.so.6]
Without --as-needed:
> readelf -d build/src/glibc-build/stdlib/tst-putenv | grep NEEDED
0x00000001 (NEEDED) Shared library:
[/build/src/glibc-build/stdlib/tst-putenvmod.so]
0x00000001 (NEEDED) Shared library: [libc.so.6]
Looking at tst-putenv.c:
char *p = getenv ("SOMETHING_NOBODY_USES");
Looking at tst-putenvmod.c
static char str[] = "SOMETHING_NOBODY_USES=something_else";
if (putenv (str) != 0)
That indicates that tst-putenv needs linked to tst-putenvmod.so and so I
stopped tst-putenv being linked with --as-needed.
#3)
make[2]: *** [/build/src/glibc-build/elf/reldep5.out] Error 127
elf/reldep5.out is empty with --as-needed and when build without
--as-needed contains:
calling fp for the first time
calling fp for the second time
second call suceeded as well
> readelf -d build/src/glibc-build/elf/reldep5 | grep NEEDED
is identical with both --as-needed and without.
The error with --as-needed is:
/build/src/glibc-build/elf/reldep5: symbol lookup error:
/build/src/glibc-build/elf/reldepmod2.so: undefined symbol: foo
elf/Makefile contains:
$(objpfx)reldep5.out: $(objpfx)reldepmod5.so $(objpfx)reldepmod6.so
The "readelf -d | grep NEEDED" output for elf/reldepmod6.so and
elf/reldepmod2.so is identical with and without --as-needed but
reldepmod5.so has
With --as-needed:
> readelf -d build/src/glibc-build/elf/reldepmod5.so | grep NEEDED
0x00000001 (NEEDED) Shared library: [libc.so.6]
Without --as-needed:
> readelf -d build/src/glibc-build/elf/reldepmod5.so | grep NEEDED
0x00000001 (NEEDED) Shared library: [libc.so.6]
0x00000001 (NEEDED) Shared library:
[/build/src/glibc-build/elf/reldepmod2.so]
And from the elf/Makefile:
$(objpfx)reldepmod5.so: $(objpfx)reldepmod2.so
>From what I understand of elf/reldep5.c, reldepmod5.so linking to
reldepmod2.so makes sense, and hence stopped reldepmod5.so linking with
--as-needed.
The rest of the test-suite failures with --as-needed are all similar to
the examples described, although some are more involved with multiple
dependencies and dependencies of dependencies being underlinked. Is
this sufficient analysis, or is this needed for all changes?
Thanks,
Allan