diff mbox series

tst-interpose-static-thread-{m,malloc-}check linking statically?

Message ID 20210721190428.dfnqd4lpqdpohy2a@begin
State New
Headers show
Series tst-interpose-static-thread-{m,malloc-}check linking statically? | expand

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent

Commit Message

Samuel Thibault July 21, 2021, 7:04 p.m. UTC
Hello,

tl;dr: I believe we want the patch below? AIUI the
tst-interpose-static-{no,}thread-{m,malloc-}check tests are supposed to
be linked completely statically?


On the GNU/Hurd port we have an issue linking the
tst-interpose-static-thread-{m,malloc-}check
tests:

gcc -pie -Wl,-O1 -nostdlib -nostartfiles -o /usr/src/glibc-upstream/build/malloc/tst-interpose-static-thread-mcheck    -Wl,-z,combreloc -Wl,-z,relro -Wl,--hash-style=both /usr/src/glibc-upstream/build/csu/Scrt1.o /usr/src/glibc-upstream/build/csu/crti.o `gcc  --print-file-name=crtbeginS.o` /usr/src/glibc-upstream/build/malloc/tst-interpose-static-thread.o /usr/src/glibc-upstream/build/support/libsupport_nonshared.a /usr/src/glibc-upstream/build/malloc/libmcheck.a /usr/src/glibc-upstream/build/malloc/tst-interpose-aux-thread.o ../htl/libpthread_syms.a /usr/src/glibc-upstream/build/htl/libpthread.a /usr/src/glibc-upstream/build/mach/libmachuser.a /usr/src/glibc-upstream/build/hurd/libhurduser.a  -Wl,-dynamic-linker=/lib/i386-gnu/ld.so.1 -Wl,-rpath-link=/usr/src/glibc-upstream/build:/usr/src/glibc-upstream/build/math:/usr/src/glibc-upstream/build/elf:/usr/src/glibc-upstream/build/dlfcn:/usr/src/glibc-upstream/build/nss:/usr/src/glibc-upstream/build/nis:/usr/src/glibc-upstream/build/rt:/usr/src/glibc-upstream/build/resolv:/usr/src/glibc-upstream/build/mathvec:/usr/src/glibc-upstream/build/support:/usr/src/glibc-upstream/build/crypt:/usr/src/glibc-upstream/build/htl:/usr/src/glibc-upstream/build/mach:/usr/src/glibc-upstream/build/hurd -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed /usr/src/glibc-upstream/build/libc.so.0.3 /usr/src/glibc-upstream/build/libc_nonshared.a -Wl,--as-needed /usr/src/glibc-upstream/build/elf/ld.so -Wl,--no-as-needed -lgcc -Wl,--as-needed -lgcc_s  -Wl,--no-as-needed `gcc  --print-file-name=crtendS.o` /usr/src/glibc-upstream/build/csu/crtn.o
/usr/bin/ld: /usr/src/glibc-upstream/build/htl/libpthread.a(pt-sysdep.o): in function `_init_routine':
/usr/src/glibc-upstream/htl/../sysdeps/mach/hurd/htl/pt-sysdep.c:88: undefined reference to `_dl_init_static_tls'
collect2: error: ld returned 1 exit status

The problem is that libpthread.a is getting linked in, but not libc.a,
and thus _dl_init_static_tls (from libc.a) is not available to
libpthread. But I'm wondering: are we supposed to support linking
libpthread statically in while not linking libc statically in? The
source code suggests me that we aren't.

Samuel

Comments

Samuel Thibault July 22, 2021, 6:36 p.m. UTC | #1
Siddhesh Poyarekar, le jeu. 22 juil. 2021 02:48:06 +0530, a ecrit:
> On 22-Jul-2021 00:34, Samuel Thibault via Libc-alpha
> <libc-alpha@sourceware.org> wrote:
> 
> > tl;dr: I believe we want the patch below? AIUI the
> > tst-interpose-static-{no,}thread-{m,malloc-}check tests are supposed to
> > be linked completely statically?
> 
> Those tests ought to be removed when malloc hooks get dropped since mcheck and
> malloc-check won't work with static libraries.

So this?  Or just excluding tst-interpose-static-thread?

diff --git a/malloc/Makefile b/malloc/Makefile
index d54285192a..0980e2901b 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -72,7 +72,8 @@ test-srcs = tst-mtrace
 # with MALLOC_CHECK_=3 because they expect a specific failure.
 tests-exclude-malloc-check = tst-malloc-check tst-malloc-usable \
 	tst-mxfast tst-safe-linking \
-	tst-compathooks-off tst-compathooks-on
+	tst-compathooks-off tst-compathooks-on \
+	tst-interpose-static-nothread tst-interpose-static-thread
 
 # Run all tests with MALLOC_CHECK_=3
 tests-malloc-check = $(filter-out $(tests-exclude-malloc-check),$(tests))
@@ -92,7 +93,8 @@ tests-exclude-mcheck = tst-mallocstate \
 	tst-malloc-thread-fail \
 	tst-malloc-usable-tunables \
 	tst-malloc_info \
-	tst-compathooks-off tst-compathooks-on
+	tst-compathooks-off tst-compathooks-on \
+	tst-interpose-static-nothread tst-interpose-static-thread
 
 tests-mcheck = $(filter-out $(tests-exclude-mcheck), $(tests))
 endif
Siddhesh Poyarekar July 23, 2021, 1:28 a.m. UTC | #2
On 7/23/21 12:06 AM, Samuel Thibault wrote:
> Siddhesh Poyarekar, le jeu. 22 juil. 2021 02:48:06 +0530, a ecrit:
>> On 22-Jul-2021 00:34, Samuel Thibault via Libc-alpha
>> <libc-alpha@sourceware.org> wrote:
>>
>>> tl;dr: I believe we want the patch below? AIUI the
>>> tst-interpose-static-{no,}thread-{m,malloc-}check tests are supposed to
>>> be linked completely statically?
>>
>> Those tests ought to be removed when malloc hooks get dropped since mcheck and
>> malloc-check won't work with static libraries.
> 
> So this?  Or just excluding tst-interpose-static-thread?

Excluding all static tets, like this:

https://patchwork.sourceware.org/project/glibc/patch/20210722140115.2911835-1-siddhesh@sourceware.org/

Could you please see if the above patch fixes it for you?

Thanks,
Siddhesh
Samuel Thibault July 23, 2021, 7:45 a.m. UTC | #3
Siddhesh Poyarekar, le ven. 23 juil. 2021 06:58:01 +0530, a ecrit:
> On 7/23/21 12:06 AM, Samuel Thibault wrote:
> > Siddhesh Poyarekar, le jeu. 22 juil. 2021 02:48:06 +0530, a ecrit:
> > > On 22-Jul-2021 00:34, Samuel Thibault via Libc-alpha
> > > <libc-alpha@sourceware.org> wrote:
> > > 
> > > > tl;dr: I believe we want the patch below? AIUI the
> > > > tst-interpose-static-{no,}thread-{m,malloc-}check tests are supposed to
> > > > be linked completely statically?
> > > 
> > > Those tests ought to be removed when malloc hooks get dropped since mcheck and
> > > malloc-check won't work with static libraries.
> > 
> > So this?  Or just excluding tst-interpose-static-thread?
> 
> Excluding all static tets, like this:
> 
> https://patchwork.sourceware.org/project/glibc/patch/20210722140115.2911835-1-siddhesh@sourceware.org/
> 
> Could you please see if the above patch fixes it for you?

Yes, that fixes it!

Samuel
Siddhesh Poyarekar July 23, 2021, 11:18 a.m. UTC | #4
On 7/23/21 1:15 PM, Samuel Thibault wrote:
>> Excluding all static tets, like this:
>>
>> https://patchwork.sourceware.org/project/glibc/patch/20210722140115.2911835-1-siddhesh@sourceware.org/
>>
>> Could you please see if the above patch fixes it for you?
> 
> Yes, that fixes it!

Thanks for confirming, could you please review the patch too?  I can 
then push it since it is a bug fix and doesn't impact ABI.

Siddhesh
diff mbox series

Patch

diff --git a/malloc/Makefile b/malloc/Makefile
index 47369b6084..fc66abe94b 100644
--- a/malloc/Makefile
+++ b/malloc/Makefile
@@ -46,7 +46,11 @@  tests := mallocbug tst-malloc tst-valloc tst-calloc tst-obstack \
 
 tests-static := \
 	 tst-interpose-static-nothread \
+	 tst-interpose-static-nothread-mcheck \
+	 tst-interpose-static-nothread-malloc-check \
 	 tst-interpose-static-thread \
+	 tst-interpose-static-thread-mcheck \
+	 tst-interpose-static-thread-malloc-check \
 	 tst-malloc-usable-static \
 
 # Test for the malloc_set_state symbol removed in glibc 2.25.