[RFC PATCH] treewide: drop librt and libpthread packages

Jo-Philipp Wich jo at mein.io
Thu Nov 18 03:58:33 PST 2021


Since OpenWrt's main libc library, musl, does not provide separate shared
object files for libpthread and librt, the existing binary packages for
them are empty placeholders which provide no runtime functionality and
frequently cause confusion among users who attempt to build software
linking -lrt or -lpthread on target.

To clean this situation up somewhat and to simplify binary package
dependecies for all of the potential musl, glibc and uclibc cases, drop
those packages and move libpthread.so as well as librt.so into the main
libc package for those libc implementations that happen ship them as
extra shared libraries.

Signed-off-by: Jo-Philipp Wich <jo at mein.io>
---
 package/devel/perf/Makefile                  |   2 +-
 package/devel/valgrind/Makefile              |   2 +-
 package/libs/libevent2/Makefile              |   2 +-
 package/libs/libnl/Makefile                  |   1 -
 package/libs/libusb/Makefile                 |   1 -
 package/libs/musl-fts/Makefile               |   1 -
 package/libs/toolchain/Makefile              | 108 ++-----------------
 package/network/config/ltq-adsl-app/Makefile |   2 +-
 package/network/config/ltq-vdsl-app/Makefile |   2 +-
 package/network/ipv6/thc-ipv6/Makefile       |   5 +-
 package/system/opkg/Makefile                 |   2 +-
 package/utils/adb/Makefile                   |   2 +-
 package/utils/mdadm/Makefile                 |   2 +-
 package/utils/util-linux/Makefile            |   1 -
 14 files changed, 16 insertions(+), 117 deletions(-)

diff --git a/package/devel/perf/Makefile b/package/devel/perf/Makefile
index bbf3aaf9ce..a5d253e94d 100644
--- a/package/devel/perf/Makefile
+++ b/package/devel/perf/Makefile
@@ -27,7 +27,7 @@ include $(INCLUDE_DIR)/nls.mk
 define Package/perf
   SECTION:=devel
   CATEGORY:=Development
-  DEPENDS:= +libelf +libdw +PACKAGE_libunwind:libunwind +libpthread +librt +objdump @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
+  DEPENDS:= +libelf +libdw +PACKAGE_libunwind:libunwind +objdump @!IN_SDK @!TARGET_arc770 @KERNEL_PERF_EVENTS
   TITLE:=Linux performance monitoring tool
   VERSION:=$(LINUX_VERSION)-$(PKG_RELEASE)
   URL:=http://www.kernel.org
diff --git a/package/devel/valgrind/Makefile b/package/devel/valgrind/Makefile
index e6ebff4b30..04a261a5c8 100644
--- a/package/devel/valgrind/Makefile
+++ b/package/devel/valgrind/Makefile
@@ -33,7 +33,7 @@ include $(INCLUDE_DIR)/kernel.mk
 define Package/valgrind
   SECTION:=devel
   CATEGORY:=Development
-  DEPENDS:=@mips||mipsel||mips64||mips64el||i386||x86_64||powerpc||arm_v7||aarch64 +libpthread +librt
+  DEPENDS:=@mips||mipsel||mips64||mips64el||i386||x86_64||powerpc||arm_v7||aarch64
   TITLE:=debugging and profiling tools for Linux
   URL:=http://www.valgrind.org
 endef
diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile
index 85c159c2a6..b6b2fdfa50 100644
--- a/package/libs/libevent2/Makefile
+++ b/package/libs/libevent2/Makefile
@@ -102,7 +102,7 @@ endef
 define Package/libevent2-pthreads
   $(call Package/libevent2/Default)
   TITLE+= Pthreads library (version 2.1)
-  DEPENDS+=+libpthread +libevent2-core
+  DEPENDS+=+libevent2-core
 endef
 
 define Package/libevent2-pthreads/description
diff --git a/package/libs/libnl/Makefile b/package/libs/libnl/Makefile
index db0c65c7a7..64e37a28d5 100644
--- a/package/libs/libnl/Makefile
+++ b/package/libs/libnl/Makefile
@@ -31,7 +31,6 @@ endef
 define Package/libnl-core
 $(call Package/libnl/default)
   TITLE:=Core Netlink Library
-  DEPENDS:=+libpthread
 endef
 
 define Package/libnl-genl
diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile
index 6b80b3848d..abf966a384 100644
--- a/package/libs/libusb/Makefile
+++ b/package/libs/libusb/Makefile
@@ -30,7 +30,6 @@ define Package/libusb-1.0
   SECTION:=libs
   CATEGORY:=Libraries
   TITLE:=A library for accessing Linux USB devices
-  DEPENDS:=+libpthread +librt
   URL:=http://libusb.info/
   ABI_VERSION:=0
 endef
diff --git a/package/libs/musl-fts/Makefile b/package/libs/musl-fts/Makefile
index 494f700f8a..b2d9843bb3 100644
--- a/package/libs/musl-fts/Makefile
+++ b/package/libs/musl-fts/Makefile
@@ -36,7 +36,6 @@ define Package/musl-fts
   CATEGORY:=Libraries
   TITLE:=fts implementation for musl libc
   URL:=https://github.com/pullmoll/musl-fts
-  DEPENDS:= +libpthread
 endef
 
 define Package/musl-fts/description
diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile
index dea99060f9..d3c571a80f 100644
--- a/package/libs/toolchain/Makefile
+++ b/package/libs/toolchain/Makefile
@@ -115,7 +115,7 @@ define Package/libasan
 $(call Package/gcc/Default)
   NAME:=libasan
   TITLE:=Runtime library for AddressSanitizer in GCC
-  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc
+  DEPENDS:=@USE_GLIBC +libstdcpp @!mips64 @!mips64el @!arc
   ABI_VERSION:=5
 endef
 
@@ -144,7 +144,7 @@ define Package/libtsan
 $(call Package/gcc/Default)
   NAME:=libtsan
   TITLE:=Runtime library for ThreadSanitizer in GCC
-  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc
+  DEPENDS:=@USE_GLIBC +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc
   ABI_VERSION:=0
 endef
 
@@ -173,7 +173,7 @@ define Package/liblsan
 $(call Package/gcc/Default)
   NAME:=liblsan
   TITLE:=Runtime library for LeakSanitizer in GCC
-  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc
+  DEPENDS:=@USE_GLIBC +libstdcpp @!mips @!mipsel @!mips64 @!mips64el @!arc
   ABI_VERSION:=0
 endef
 
@@ -202,7 +202,7 @@ define Package/libubsan
 $(call Package/gcc/Default)
   NAME:=libubsan
   TITLE:=Runtime library for UndefinedBehaviorSanitizer in GCC
-  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc
+  DEPENDS:=@USE_GLIBC +libstdcpp @!mips64 @!mips64el @!arc
   ABI_VERSION:=1
 endef
 
@@ -256,33 +256,7 @@ define Package/libc/config
 		string
 		prompt "libc shared library files (use wildcards)"
 		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
-		default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*,.so}"
-
-	endmenu
-endef
-
-
-define Package/libpthread
-$(call Package/libc/Default)
-  TITLE:=POSIX thread library
-endef
-
-define Package/libpthread/config
-	menu "Configuration"
-	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
-
-	config LIBPTHREAD_ROOT_DIR
-		string
-		prompt "libpthread shared library base directory"
-		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
-		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
-		default "/"  if NATIVE_TOOLCHAIN
-
-	config LIBPTHREAD_FILE_SPEC
-		string
-		prompt "libpthread shared library files (use wildcards)"
-		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
-		default "./lib/libpthread{-*.so,.so.*}"
+		default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,pthread,resolv,rt,util}{-*.so,.so.*,.so}"
 
 	endmenu
 endef
@@ -314,33 +288,6 @@ define Package/libthread-db/config
 	endmenu
 endef
 
-define Package/librt
-$(call Package/libc/Default)
-  TITLE:=POSIX.1b RealTime extension library
-  DEPENDS:=+libpthread
-endef
-
-define Package/librt/config
-	menu "Configuration"
-	depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
-
-	config LIBRT_ROOT_DIR
-		string
-		prompt "librt shared library base directory"
-		depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
-		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
-		default "/"  if NATIVE_TOOLCHAIN
-
-	config LIBRT_FILE_SPEC
-		string
-		prompt "librt shared library files (use wildcards)"
-		depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
-		default "./lib/librt{-*.so,.so.*}"
-
-	endmenu
-endef
-
-
 define Package/libgfortran
 $(call Package/gcc/Default)
   TITLE:=GFortran support library
@@ -521,7 +468,7 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
 		$(TOOLCHAIN_DIR)/lib/ld*.so.* \
 		$(TOOLCHAIN_DIR)/lib/ld-$(LIBC_SO_VERSION).so \
 		$(1)/lib/
-	for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libresolv libutil; do \
+	for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libpthread libresolv librt libutil; do \
 		for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.* $(TOOLCHAIN_DIR)/lib/$$$$file-$(LIBC_SO_VERSION).so; do \
 			if [ -e "$$$$file" ]; then \
 				$(CP) $$$$file $(1)/lib/; \
@@ -550,42 +497,19 @@ ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
   define Package/libc/install_lib
 	$(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
 	$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
+	$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
 	$(if $(LIBGCC_MAP), \
 		$(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
 		$(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
 	)
   endef
 
-  define Package/libpthread/install
-	$(INSTALL_DIR) $(1)/lib
-  ifneq ($(CONFIG_USE_MUSL),y)
-	$(CP) \
-		$(TOOLCHAIN_DIR)/lib/libpthread.so.* \
-		$(TOOLCHAIN_DIR)/lib/libpthread-$(LIBC_SO_VERSION).so \
-		$(1)/lib/
-  endif
-  endef
-
   define Package/libthread-db/install
 	$(INSTALL_DIR) $(1)/lib
 	$(CP) \
 		$(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
   endef
 
-  define Package/libpthread/install_lib
-	$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
-  endef
-
-  define Package/librt/install
-	$(INSTALL_DIR) $(1)/lib
-  ifneq ($(CONFIG_USE_MUSL),y)
-	$(CP) \
-		$(TOOLCHAIN_DIR)/lib/librt.so.* \
-		$(TOOLCHAIN_DIR)/lib/librt-$(LIBC_SO_VERSION).so \
-		$(1)/lib/
-  endif
-  endef
-
   define Package/ldd/install
 	$(INSTALL_DIR) $(1)/usr/bin/
 	$(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
@@ -662,14 +586,6 @@ else
 	exit 0
   endef
 
-  define Package/libpthread/install
-	for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
-		$(INSTALL_DIR) $(1)/lib ; \
-		$(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \
-	done ; \
-	exit 0
-  endef
-
   define Package/libthread-db/install
 	for file in $(call qstrip,$(CONFIG_LIBTHREAD_DB_FILE_SPEC)); do \
 		$(INSTALL_DIR) $(1)/lib ; \
@@ -678,14 +594,6 @@ else
 	exit 0
   endef
 
-  define Package/librt/install
-	for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
-		$(INSTALL_DIR) $(1)/lib ; \
-		$(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \
-	done ; \
-	exit 0
-  endef
-
   define Package/libatomic/install
 	for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
 		$(INSTALL_DIR) $(1)/lib ; \
@@ -730,9 +638,7 @@ $(eval $(call BuildPackage,libasan))
 $(eval $(call BuildPackage,libtsan))
 $(eval $(call BuildPackage,liblsan))
 $(eval $(call BuildPackage,libubsan))
-$(eval $(call BuildPackage,libpthread))
 $(eval $(call BuildPackage,libthread-db))
-$(eval $(call BuildPackage,librt))
 $(eval $(call BuildPackage,libgfortran))
 $(eval $(call BuildPackage,libgomp))
 $(eval $(call BuildPackage,ldd))
diff --git a/package/network/config/ltq-adsl-app/Makefile b/package/network/config/ltq-adsl-app/Makefile
index 2e4792266c..bef542498a 100644
--- a/package/network/config/ltq-adsl-app/Makefile
+++ b/package/network/config/ltq-adsl-app/Makefile
@@ -35,7 +35,7 @@ define Package/ltq-adsl-app
   CATEGORY:=Network
   TITLE:=Lantiq DSL userland tool
   URL:=http://www.lantiq.com/
-  DEPENDS:=@(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy||TARGET_lantiq_ase) +libpthread +ltq-dsl-base +libubox +libubus
+  DEPENDS:=@(TARGET_lantiq_xway||TARGET_lantiq_xway_legacy||TARGET_lantiq_ase) +ltq-dsl-base +libubox +libubus
   MENU:=1
 endef
 
diff --git a/package/network/config/ltq-vdsl-app/Makefile b/package/network/config/ltq-vdsl-app/Makefile
index 0051f39b31..b28e240b17 100644
--- a/package/network/config/ltq-vdsl-app/Makefile
+++ b/package/network/config/ltq-vdsl-app/Makefile
@@ -29,7 +29,7 @@ define Package/ltq-vdsl-app
   CATEGORY:=Network
   TITLE:=Lantiq VDSL userland tool
   URL:=http://www.lantiq.com/
-  DEPENDS:=@TARGET_lantiq_xrx200 +libpthread +librt +ltq-dsl-base +libubox +libubus
+  DEPENDS:=@TARGET_lantiq_xrx200 +ltq-dsl-base +libubox +libubus
 endef
 
 define Package/ltq-vdsl-app/description
diff --git a/package/network/ipv6/thc-ipv6/Makefile b/package/network/ipv6/thc-ipv6/Makefile
index 91bacf625e..ec39bd1c63 100644
--- a/package/network/ipv6/thc-ipv6/Makefile
+++ b/package/network/ipv6/thc-ipv6/Makefile
@@ -33,15 +33,12 @@ THC_APPLETS := \
 	randicmp6 redir6 rsmurf6 sendpees6 sendpeesmp6 smurf6 thcping6        \
 	toobig6 trace6
 
-THC_DEPENDS_dnsdict6 := +libpthread
-THC_DEPENDS_thcping6 := +librt
-
 define BuildTool
   define Package/thc-ipv6-$(subst _,-,$(1))
     TITLE:=THC-IPv6 $(1) utility
     SECTION:=net
     CATEGORY:=Network
-    DEPENDS:=+libpcap $(THC_DEPENDS_$(1))
+    DEPENDS:=+libpcap
     URL:=https://github.com/vanhauser-thc/thc-ipv6
     SUBMENU:=THC-IPv6 attack and analyzing toolkit
   endef
diff --git a/package/system/opkg/Makefile b/package/system/opkg/Makefile
index bd9fab474c..d56e95c9a6 100644
--- a/package/system/opkg/Makefile
+++ b/package/system/opkg/Makefile
@@ -36,7 +36,7 @@ define Package/opkg
   SECTION:=base
   CATEGORY:=Base system
   TITLE:=opkg package manager
-  DEPENDS:=+uclient-fetch +libpthread +libubox
+  DEPENDS:=+uclient-fetch +libubox
   URL:=$(PKG_SOURCE_URL)
   MENU:=1
 endef
diff --git a/package/utils/adb/Makefile b/package/utils/adb/Makefile
index 0482a40da1..00d9fd7e73 100644
--- a/package/utils/adb/Makefile
+++ b/package/utils/adb/Makefile
@@ -26,7 +26,7 @@ define Package/adb
   CATEGORY:=Utilities
   TITLE:=Android Debug Bridge CLI tool
   URL:=http://tools.android.com/
-  DEPENDS:=+zlib +libopenssl +libpthread
+  DEPENDS:=+zlib +libopenssl
 endef
 
 define Package/adb/description
diff --git a/package/utils/mdadm/Makefile b/package/utils/mdadm/Makefile
index f20a58b704..eb4afe9613 100644
--- a/package/utils/mdadm/Makefile
+++ b/package/utils/mdadm/Makefile
@@ -28,7 +28,7 @@ define Package/mdadm
   SUBMENU:=Disc
   TITLE:=A tool for managing Soft RAID under Linux
   URL:=https://www.kernel.org/pub/linux/utils/raid/mdadm/
-  DEPENDS:=+libpthread +kmod-md-mod +kmod-md-raid0 +kmod-md-raid10 +kmod-md-raid1
+  DEPENDS:=+kmod-md-mod +kmod-md-raid0 +kmod-md-raid10 +kmod-md-raid1
 endef
 
 define Package/mdadm/description
diff --git a/package/utils/util-linux/Makefile b/package/utils/util-linux/Makefile
index 74f3f17469..532069bf4d 100644
--- a/package/utils/util-linux/Makefile
+++ b/package/utils/util-linux/Makefile
@@ -37,7 +37,6 @@ include $(INCLUDE_DIR)/package.mk
 define Package/util-linux/Default
   SECTION:=utils
   CATEGORY:=Utilities
-  DEPENDS:= +librt
   URL:=http://www.kernel.org/pub/linux/utils/util-linux/
 endef
 
-- 
2.30.2




More information about the openwrt-devel mailing list