[7/8] nptl: Do not install libpthread.so and do not link tests with it

Message ID e9d228ad5eb41c16b006f46a10b88750569b51fe.1621600831.git.fweimer@redhat.com
State New
Headers show
Series
  • nptl: Complete libpthread move
Related show

Commit Message

Noah Goldstein via Libc-alpha May 21, 2021, 12:46 p.m.
Keep installing libpthread.a, so that -lpthread works.
---
 nptl/Makefile           | 30 +++++-------------------------
 sysdeps/nptl/Makeconfig |  8 ++++++--
 2 files changed, 11 insertions(+), 27 deletions(-)

-- 
2.31.1

Comments

Noah Goldstein via Libc-alpha May 24, 2021, 5:14 p.m. | #1
On 21/05/2021 09:46, Florian Weimer via Libc-alpha wrote:
> Keep installing libpthread.a, so that -lpthread works.


LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>


> ---

>  nptl/Makefile           | 30 +++++-------------------------

>  sysdeps/nptl/Makeconfig |  8 ++++++--

>  2 files changed, 11 insertions(+), 27 deletions(-)

> 

> diff --git a/nptl/Makefile b/nptl/Makefile

> index 64cd0dcbf6..52d1d193d9 100644

> --- a/nptl/Makefile

> +++ b/nptl/Makefile

> @@ -204,12 +204,15 @@ routines = \

>    unwind \

>    vars \

>  

> -shared-only-routines = forward

>  static-only-routines = pthread_atfork

> -

>  libpthread-routines = libpthread-compat

>  libpthread-shared-only-routines = libpthread-compat

>  

> +# Pretend that libpthread.so is a linker script, so that the symbolic

> +# link is not installed.

> +install-lib-ldscripts = libpthread.so

> +$(inst_libdir)/libpthread.so:

> +

>  # Since cancellation handling is in large parts handled using exceptions

>  # we have to compile some files with exception handling enabled, some

>  # even with asynchronous unwind tables.


Ok.

> @@ -374,8 +377,6 @@ else

>  tests-printers-libs := $(static-thread-library)

>  endif

>  

> -LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete

> -

>  tests += tst-cancelx7 tst-cancelx17

>  

>  ifeq ($(build-shared),yes)


Ok.

> @@ -469,7 +470,6 @@ ifeq (yes,$(build-shared))

>  lib-noranlib: $(addprefix $(objpfx),$(extra-objs))

>  endif

>  

> -

>  # 'pthread_self' is a simple memory or register load.  Setting up the

>  # stack frame is more work than the actual operation.  Disable the

>  # frame creation entirely.  This will help applications which call the


Spurious line removal.

> @@ -548,35 +548,15 @@ else

>  librt = $(common-objpfx)rt/librt.a

>  endif

>  

> -# `make check' sometimes triggers a rebuild of librt.so using this Makefile,

> -# which ignores librt's dependence on libpthread

> -$(common-objpfx)rt/librt.so: $(shared-thread-library)

> -

>  $(objpfx)tst-cancel17: $(librt)

>  $(objpfx)tst-cancelx17: $(librt)

>  

>  LDLIBS-tst-cancel24 = -Wl,--no-as-needed -lstdc++

>  LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)

>  

> -# 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)

>  generated += multidir.mk tst-tls6.out

>  endif

>  


Ok.

> diff --git a/sysdeps/nptl/Makeconfig b/sysdeps/nptl/Makeconfig

> index 8757ec868b..8a9407925c 100644

> --- a/sysdeps/nptl/Makeconfig

> +++ b/sysdeps/nptl/Makeconfig

> @@ -21,7 +21,11 @@

>  

>  have-thread-library = yes

>  

> -shared-thread-library = $(common-objpfx)nptl/libpthread.so

> -static-thread-library = $(common-objpfx)nptl/libpthread.a

> +# The thread library is integrated.

> +shared-thread-library =

> +static-thread-library =

>  

> +# Some tests need this to load their own test objects, and system

> +# libraries used by memusagestat need to link against the empty

> +# libpthread.so.0, not the (potentially non-empty) system version.

>  rpath-dirs += nptl

> 


Ok.

Patch

diff --git a/nptl/Makefile b/nptl/Makefile
index 64cd0dcbf6..52d1d193d9 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -204,12 +204,15 @@  routines = \
   unwind \
   vars \
 
-shared-only-routines = forward
 static-only-routines = pthread_atfork
-
 libpthread-routines = libpthread-compat
 libpthread-shared-only-routines = libpthread-compat
 
+# Pretend that libpthread.so is a linker script, so that the symbolic
+# link is not installed.
+install-lib-ldscripts = libpthread.so
+$(inst_libdir)/libpthread.so:
+
 # Since cancellation handling is in large parts handled using exceptions
 # we have to compile some files with exception handling enabled, some
 # even with asynchronous unwind tables.
@@ -374,8 +377,6 @@  else
 tests-printers-libs := $(static-thread-library)
 endif
 
-LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete
-
 tests += tst-cancelx7 tst-cancelx17
 
 ifeq ($(build-shared),yes)
@@ -469,7 +470,6 @@  ifeq (yes,$(build-shared))
 lib-noranlib: $(addprefix $(objpfx),$(extra-objs))
 endif
 
-
 # 'pthread_self' is a simple memory or register load.  Setting up the
 # stack frame is more work than the actual operation.  Disable the
 # frame creation entirely.  This will help applications which call the
@@ -548,35 +548,15 @@  else
 librt = $(common-objpfx)rt/librt.a
 endif
 
-# `make check' sometimes triggers a rebuild of librt.so using this Makefile,
-# which ignores librt's dependence on libpthread
-$(common-objpfx)rt/librt.so: $(shared-thread-library)
-
 $(objpfx)tst-cancel17: $(librt)
 $(objpfx)tst-cancelx17: $(librt)
 
 LDLIBS-tst-cancel24 = -Wl,--no-as-needed -lstdc++
 LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)
 
-# 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)
 generated += multidir.mk tst-tls6.out
 endif
 
diff --git a/sysdeps/nptl/Makeconfig b/sysdeps/nptl/Makeconfig
index 8757ec868b..8a9407925c 100644
--- a/sysdeps/nptl/Makeconfig
+++ b/sysdeps/nptl/Makeconfig
@@ -21,7 +21,11 @@ 
 
 have-thread-library = yes
 
-shared-thread-library = $(common-objpfx)nptl/libpthread.so
-static-thread-library = $(common-objpfx)nptl/libpthread.a
+# The thread library is integrated.
+shared-thread-library =
+static-thread-library =
 
+# Some tests need this to load their own test objects, and system
+# libraries used by memusagestat need to link against the empty
+# libpthread.so.0, not the (potentially non-empty) system version.
 rpath-dirs += nptl