@@ -203,3 +203,21 @@ libc-link.so = $(common-objpfx)libc.so
extra-B-pthread.so = -B$(common-objpfx)htl/
include ../Rules
+
+# Make sure we link with the thread library.
+ifeq ($(build-shared),yes)
+$(addprefix $(objpfx), \
+ $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
+ $(tests-nolibpthread), \
+ $(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-container))): \
+ $(objpfx)libpthread.so
+$(objpfx)tst-unload: $(libdl)
+# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# since otherwise libpthread.so comes before libc.so when linking.
+$(addprefix $(objpfx), $(tests-reverse)): \
+ $(objpfx)../libc.so $(objpfx)libpthread.so
+$(objpfx)../libc.so: $(common-objpfx)libc.so ;
+$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
+else
+$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
+endif
@@ -569,6 +569,24 @@ $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
$(objpfx)libpthread.so: +preinit += $(addprefix $(objpfx),$(crti-objs))
$(objpfx)libpthread.so: +postinit += $(addprefix $(objpfx),$(crtn-objs))
+# Make sure we link with the thread library.
+ifeq ($(build-shared),yes)
+$(addprefix $(objpfx), \
+ $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
+ $(tests-nolibpthread), \
+ $(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-container))): \
+ $(objpfx)libpthread.so
+$(objpfx)tst-unload: $(libdl)
+# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
+# since otherwise libpthread.so comes before libc.so when linking.
+$(addprefix $(objpfx), $(tests-reverse)): \
+ $(objpfx)../libc.so $(objpfx)libpthread.so
+$(objpfx)../libc.so: $(common-objpfx)libc.so ;
+$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
+else
+$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
+endif
+
ifeq ($(build-shared),yes)
$(objpfx)crti.o: $(objpfx)pt-crti.o
ln -f $< $@
@@ -228,22 +228,4 @@ LDFLAGS-tst-join7mod.so = -Wl,-soname,tst-join7mod.so
CFLAGS-tst-unwind-thread.c += -funwind-tables
-# Make sure we link with the thread library.
-ifeq ($(build-shared),yes)
-$(addprefix $(objpfx), \
- $(filter-out $(tests-static) $(xtests-static) $(tests-reverse) \
- $(tests-nolibpthread), \
- $(tests) $(tests-internal) $(xtests) $(test-srcs) $(tests-container))): \
- $(objpfx)libpthread.so
-$(objpfx)tst-unload: $(libdl)
-# $(objpfx)../libc.so is used instead of $(common-objpfx)libc.so,
-# since otherwise libpthread.so comes before libc.so when linking.
-$(addprefix $(objpfx), $(tests-reverse)): \
- $(objpfx)../libc.so $(objpfx)libpthread.so
-$(objpfx)../libc.so: $(common-objpfx)libc.so ;
-$(addprefix $(objpfx),$(tests-static) $(xtests-static)): $(objpfx)libpthread.a
-else
-$(addprefix $(objpfx),$(tests) $(test-srcs)): $(objpfx)libpthread.a
-endif
-
endif