public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Do not install shared objects under versioned names
@ 2021-06-10  8:22 Florian Weimer
  2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:22 UTC (permalink / raw)
  To: libc-alpha

This is essentially a repost of the “Add --disable-major-minor-libraries
configure option” series.  Joseph suggested that the configure option is
not needed, so this version implements the change unconditionally.

Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two
build-many-glibcs.py trees with and without these patches, using this
command to see if there are missing files besides the versioned DSOs or
any dangling symbolic links.

cd /home/bmg/install/glibcs && find -printf '%P\n' \
  | while read x ; do
    test -r /home/bmg-install-glibcs/$x || echo $x
  done \
  | grep -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'

/home/bmg/install/glibcs is the unpatched build,
/home/bmg-install-glibcs is the build with the patches applied.  As
expected, there was no output.

Thanks,
Florian

Florian Weimer (4):
  nptl_db: Install libthread_db under a regular implementation name
  Makerules: Remove lib-version, $(subdir-version)
  elf: Generalize name-based DSO recognition in ldconfig
  Install shared objects under their ABI names

 INSTALL             | 10 +++++++
 Makefile            |  6 ----
 Makerules           | 67 +++++----------------------------------------
 NEWS                |  8 ++++++
 elf/Makefile        | 12 ++------
 elf/dl-is_dso.h     | 33 ++++++++++++++++++++++
 elf/ldconfig.c      |  5 ++--
 elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++
 nptl_db/Makefile    |  2 --
 9 files changed, 98 insertions(+), 80 deletions(-)
 create mode 100644 elf/dl-is_dso.h
 create mode 100644 elf/tst-dl-is_dso.c

-- 
2.31.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
@ 2021-06-10  8:23 ` Florian Weimer
  2021-06-27 21:32   ` Carlos O'Donell
  2021-06-10  8:23 ` [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) Florian Weimer
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:23 UTC (permalink / raw)
  To: libc-alpha

Currently, the name is always libthread_db-1.0.so.  It does not change
with the glibc version, like the other libraries.

GDB hard-codes libthread_db.so.1 (the soname), so this change does not
affect loading libthread_db.

Tested on x86_64-linux-gnu, in an environment where the nptl GDB tests
actually run.
---
 nptl_db/Makefile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/nptl_db/Makefile b/nptl_db/Makefile
index ea721c1dcf..1f79c018a1 100644
--- a/nptl_db/Makefile
+++ b/nptl_db/Makefile
@@ -21,8 +21,6 @@ subdir          := nptl_db
 
 include ../Makeconfig
 
-nptl_db-version = 1.0
-
 extra-libs = libthread_db
 extra-libs-others := $(extra-libs)
 
-- 
2.31.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version)
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
  2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
@ 2021-06-10  8:23 ` Florian Weimer
  2021-06-27 21:32   ` Carlos O'Donell
  2021-06-10  8:23 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:23 UTC (permalink / raw)
  To: libc-alpha

Also clarify that the “versioned” term refers to the soname, not the glibc
version (which also ends up in the installed file name).

I verified on x86_64-linux-gnu that “make install” produces the same
files.
---
 Makerules | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/Makerules b/Makerules
index ca9885436e..d3f29d0b89 100644
--- a/Makerules
+++ b/Makerules
@@ -982,22 +982,21 @@ install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
 install-lib := $(filter-out %.so %_pic.a,$(install-lib))
 
 ifeq (yes,$(build-shared))
-# Find which .so's have versions.
+# Find which .so's have a version number in their soname.
 versioned := $(strip $(foreach so,$(install-lib.so),\
 			       $(patsubst %,$(so),$($(so)-version))))
 
 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
 
-# For versioned libraries, we install three files:
+# For libraries whose soname have version numbers, we install three files:
 #	$(inst_libdir)/libfoo.so	-- for linking, symlink or ld script
 #	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME, symlink
 #	$(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
-lib-version := $(firstword $($(subdir)-version) $(version))
 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
 		      $(foreach L,$(install-lib.so-versioned),\
 				$(inst_libdir)/$L \
-				$(inst_slibdir)/$(L:.so=)-$(lib-version).so \
+				$(inst_slibdir)/$(L:.so=)-$(version).so \
 				$(inst_slibdir)/$L$($L-version))
 
 # Install all the unversioned shared libraries.
@@ -1125,7 +1124,6 @@ include $(o-iterator)
 
 generated += $(foreach o,$(versioned),$o$($o-version))
 
-ifeq (,$($(subdir)-version))
 define o-iterator-doit
 $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
 				 $(+force);
@@ -1140,23 +1138,7 @@ $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
 endef
 object-suffixes-left := $(versioned)
 include $(o-iterator)
-else
-define o-iterator-doit
-$(inst_slibdir)/$o$($o-version): \
-  $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
-	$$(make-shlib-link)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-
-define o-iterator-doit
-$(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
-	$$(do-install-program)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-endif
-endif
+endif # ifneq (,$(versioned))
 
 define do-install-so
 $(do-install-program)
-- 
2.31.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
  2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
  2021-06-10  8:23 ` [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) Florian Weimer
@ 2021-06-10  8:23 ` Florian Weimer
  2021-06-27 21:32   ` Carlos O'Donell
  2021-06-10  8:23 ` [PATCH 4/4] Install shared objects under their ABI names Florian Weimer
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:23 UTC (permalink / raw)
  To: libc-alpha

This introduces <dl-is_dso.h> and the _dl_is_dso function.  A
test ensures that the official names of libc.so, ld.so, and their
versioned names are recognized.
---
 elf/Makefile        |  2 +-
 elf/dl-is_dso.h     | 33 +++++++++++++++++++++++++++++++++
 elf/ldconfig.c      |  5 ++---
 elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 4 deletions(-)
 create mode 100644 elf/dl-is_dso.h
 create mode 100644 elf/tst-dl-is_dso.c

diff --git a/elf/Makefile b/elf/Makefile
index 5c47daee12..1751f5ec67 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -223,7 +223,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-single_threaded tst-single_threaded-pthread \
 	 tst-tls-ie tst-tls-ie-dlmopen argv0test \
 	 tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \
-	 tst-tls20 tst-tls21 tst-dlmopen-dlerror
+	 tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dl-is_dso
 #	 reldep9
 tests-internal += loadtest unload unload2 circleload1 \
 	 neededtest neededtest2 neededtest3 neededtest4 \
diff --git a/elf/dl-is_dso.h b/elf/dl-is_dso.h
new file mode 100644
index 0000000000..94e00966a1
--- /dev/null
+++ b/elf/dl-is_dso.h
@@ -0,0 +1,33 @@
+/* Heuristic for recognizing DSO file names.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdbool.h>
+#include <string.h>
+
+/* Returns true if the file name looks like a DSO name.  */
+static bool
+_dl_is_dso (const char *name)
+{
+  /* Recognize lib*.so*, ld-*.so*, ld.so.*, ld64.so.*.  ld-*.so*
+     matches both platform dynamic linker names like ld-linux.so.2,
+     and versioned dynamic loader names like ld-2.12.so.  */
+  return (((strncmp (name, "lib", 3) == 0 || strncmp (name, "ld-", 3) == 0)
+           && strstr (name, ".so") != NULL)
+          || strncmp (name, "ld.so.", 6) == 0
+          || strncmp (name, "ld64.so.", 8) == 0);
+}
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 96bf7700b2..1037e8d0cf 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -43,6 +43,7 @@
 #include <ldconfig.h>
 #include <dl-cache.h>
 #include <dl-hwcaps.h>
+#include <dl-is_dso.h>
 
 #include <dl-procinfo.h>
 
@@ -842,9 +843,7 @@ search_dir (const struct dir_entry *entry)
 	 subdirectory (if not already processing a glibc-hwcaps
 	 subdirectory)?  The dynamic linker is also considered as
 	 shared library.  */
-      if (((strncmp (direntry->d_name, "lib", 3) != 0
-	    && strncmp (direntry->d_name, "ld-", 3) != 0)
-	   || strstr (direntry->d_name, ".so") == NULL)
+      if (!_dl_is_dso (direntry->d_name)
 	  && (direntry->d_type == DT_REG
 	      || (entry->hwcaps == NULL
 		  && !is_hwcap_platform (direntry->d_name))))
diff --git a/elf/tst-dl-is_dso.c b/elf/tst-dl-is_dso.c
new file mode 100644
index 0000000000..48d2cc9fbe
--- /dev/null
+++ b/elf/tst-dl-is_dso.c
@@ -0,0 +1,35 @@
+/* Test heuristic for recognizing DSO file names.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <dl-is_dso.h>
+#include <gnu/lib-names.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  /* Official ABI names.  */
+  TEST_VERIFY (_dl_is_dso (LIBC_SO));
+  TEST_VERIFY (_dl_is_dso (LD_SO));
+  /* Version-based names.  The version number does not matter.  */
+  TEST_VERIFY (_dl_is_dso ("libc-2.12.so"));
+  TEST_VERIFY (_dl_is_dso ("ld-2.12.so"));
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.31.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/4] Install shared objects under their ABI names
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
                   ` (2 preceding siblings ...)
  2021-06-10  8:23 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer
@ 2021-06-10  8:23 ` Florian Weimer
  2021-06-27 21:32   ` Carlos O'Donell
  2021-06-14 11:04 ` [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:23 UTC (permalink / raw)
  To: libc-alpha

Previously, the installed objects were named like libc-2.33.so,
and the ABI soname libc.so.6 was just a symbolic link.

The Makefile targets to install these symbolic links are no longer
needed after this, so they are removed with this commit.  The more
general $(make-link) command (which invokes scripts/rellns-sh) is
retained because other symbolic links are still needed.
---
 INSTALL      | 10 ++++++++++
 Makefile     |  6 ------
 Makerules    | 45 +++++----------------------------------------
 NEWS         |  8 ++++++++
 elf/Makefile | 10 ++--------
 5 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/INSTALL b/INSTALL
index bc761ab98b..ed5f66489b 100644
--- a/INSTALL
+++ b/INSTALL
@@ -199,6 +199,16 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
      RELRO and a read-only global offset table (GOT), at the cost of
      slightly increased program load times.
 
+'--disable-major-minor-libraries'
+     Do not install shared objects under file names that contain the
+     major and minor version of the GNU C Library.  By default, such
+     names are used, and the names defined by the ABI are provided as
+     symbolic links only.  This causes problems with certain package
+     managers during library upgrades and (in particular) downgrades, so
+     this option can be used to install these shared objects directly
+     under their ABI-defined names, without an additional indirection
+     via symbolic links.
+
 '--enable-pt_chown'
      The file 'pt_chown' is a helper binary for 'grantpt' (*note
      Pseudo-Terminals: Allocation.) that is installed setuid root to fix
diff --git a/Makefile b/Makefile
index 242d36de91..c115c652a0 100644
--- a/Makefile
+++ b/Makefile
@@ -109,12 +109,6 @@ elf/ldso_install:
 # Ignore the error if we cannot update /etc/ld.so.cache.
 ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
-install: install-symbolic-link
-.PHONY: install-symbolic-link
-install-symbolic-link: subdir_install
-	$(symbolic-link-prog) $(symbolic-link-list)
-	rm -f $(symbolic-link-list)
-
 install:
 	-test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
 	  $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
diff --git a/Makerules b/Makerules
index d3f29d0b89..6efff78fbe 100644
--- a/Makerules
+++ b/Makerules
@@ -989,14 +989,12 @@ versioned := $(strip $(foreach so,$(install-lib.so),\
 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
 
-# For libraries whose soname have version numbers, we install three files:
+# For libraries whose soname have version numbers, we install two files:
 #	$(inst_libdir)/libfoo.so	-- for linking, symlink or ld script
-#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME, symlink
-#	$(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
+#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME
 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
 		      $(foreach L,$(install-lib.so-versioned),\
 				$(inst_libdir)/$L \
-				$(inst_slibdir)/$(L:.so=)-$(version).so \
 				$(inst_slibdir)/$L$($L-version))
 
 # Install all the unversioned shared libraries.
@@ -1029,35 +1027,10 @@ ln -f $(objpfx)/$(@F) $@
 endef
 endif
 
-ifeq (yes,$(build-shared))
-ifeq (no,$(cross-compiling))
-symbolic-link-prog := $(elf-objpfx)sln
-symbolic-link-list := $(elf-objpfx)symlink.list
-define make-shlib-link
-echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
-endef
-else # cross-compiling
-# We need a definition that can be used by elf/Makefile's install rules.
-symbolic-link-prog = $(LN_S)
-endif
-endif
-ifndef make-shlib-link
-define make-shlib-link
-rm -f $@
-$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
-endef
-endif
-
 ifdef libc.so-version
-# For a library specified to be version N, install three files:
-# libc.so	->	libc.so.N	(e.g. libc.so.6)
-# libc.so.6	->	libc-VERSION.so	(e.g. libc-1.10.so)
-
-$(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
-					   $(+force)
-	$(make-shlib-link)
-$(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
+$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
 	$(do-install-program)
+
 install: $(inst_slibdir)/libc.so$(libc.so-version)
 
 # This fragment of linker script gives the OUTPUT_FORMAT statement
@@ -1125,15 +1098,7 @@ include $(o-iterator)
 generated += $(foreach o,$(versioned),$o$($o-version))
 
 define o-iterator-doit
-$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
-				 $(+force);
-	$$(make-shlib-link)
-endef
-object-suffixes-left := $(versioned)
-include $(o-iterator)
-
-define o-iterator-doit
-$(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
+$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
 	$$(do-install-program)
 endef
 object-suffixes-left := $(versioned)
diff --git a/NEWS b/NEWS
index 1bf3daa502..1634e20ce5 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,14 @@ Deprecated and removed features, and other changes affecting compatibility:
 * The function pthread_yield has been deprecated; programs should use
   the equivalent standard function sched_yield instead.
 
+* Previously, glibc installed its various shared objects under versioned
+  file names such as libc-2.33.so.  The ABI sonames (e.g., libc.so.6)
+  were provided as symbolic links.  Starting with glibc 2.34, the shared
+  objects are installed under their ABI sonames directly, without
+  symbolic links.  This increases compatibility with distribution
+  package managers that delete removed files late during the package
+  upgrade or downgrade process.
+
 Changes to build and runtime requirements:
 
 * On Linux, the shm_open, sem_open, and related functions now expect the
diff --git a/elf/Makefile b/elf/Makefile
index 1751f5ec67..02f634c192 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -628,20 +628,14 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
 CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
 
 ifeq (yes,$(build-shared))
-$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
+$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force)
 	$(make-target-directory)
 	$(do-install-program)
 
-$(inst_rtlddir)/$(rtld-installed-name): \
-  $(inst_slibdir)/$(rtld-version-installed-name) \
-  $(inst_slibdir)/libc-$(version).so
-	$(make-target-directory)
-	$(make-shlib-link)
-
 # Special target called by parent to install just the dynamic linker.
 .PHONY: ldso_install
 ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
-endif
+endif # $(build-shared)
 
 
 # Workarounds for ${exec_prefix} expansion in configure variables.
-- 
2.31.1


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/4] Do not install shared objects under versioned names
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
                   ` (3 preceding siblings ...)
  2021-06-10  8:23 ` [PATCH 4/4] Install shared objects under their ABI names Florian Weimer
@ 2021-06-14 11:04 ` Florian Weimer
  2021-06-14 14:49 ` Siddhesh Poyarekar
  2021-06-27 21:31 ` Carlos O'Donell
  6 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-06-14 11:04 UTC (permalink / raw)
  To: Florian Weimer via Libc-alpha

* Florian Weimer via Libc-alpha:

> This is essentially a repost of the “Add --disable-major-minor-libraries
> configure option” series.  Joseph suggested that the configure option is
> not needed, so this version implements the change unconditionally.
>
> Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two
> build-many-glibcs.py trees with and without these patches, using this
> command to see if there are missing files besides the versioned DSOs or
> any dangling symbolic links.
>
> cd /home/bmg/install/glibcs && find -printf '%P\n' \
>   | while read x ; do
>     test -r /home/bmg-install-glibcs/$x || echo $x
>   done \
>   | grep -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'
>
> /home/bmg/install/glibcs is the unpatched build,
> /home/bmg-install-glibcs is the build with the patches applied.  As
> expected, there was no output.

What are general thoughts about this change?  Should we do it?

If there's an emerging consensus that we want it, I can backport it
downstream because we really need it there, and drop the patches once
they have been merged.  But I really don't want to carry another bunch
of downstream-only patches indefinitely.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/4] Do not install shared objects under versioned names
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
                   ` (4 preceding siblings ...)
  2021-06-14 11:04 ` [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
@ 2021-06-14 14:49 ` Siddhesh Poyarekar
  2021-06-27 20:43   ` Carlos O'Donell
  2021-06-27 21:31 ` Carlos O'Donell
  6 siblings, 1 reply; 15+ messages in thread
From: Siddhesh Poyarekar @ 2021-06-14 14:49 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 1:52 PM, Florian Weimer via Libc-alpha wrote:
> This is essentially a repost of the “Add --disable-major-minor-libraries
> configure option” series.  Joseph suggested that the configure option is
> not needed, so this version implements the change unconditionally.
> 
> Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two
> build-many-glibcs.py trees with and without these patches, using this
> command to see if there are missing files besides the versioned DSOs or
> any dangling symbolic links.
> 
> cd /home/bmg/install/glibcs && find -printf '%P\n' \
>    | while read x ; do
>      test -r /home/bmg-install-glibcs/$x || echo $x
>    done \
>    | grep -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'
> 
> /home/bmg/install/glibcs is the unpatched build,
> /home/bmg-install-glibcs is the build with the patches applied.  As
> expected, there was no output.

I was hoping that we would go in the opposite direction with this, i.e. 
encode a unique identifier in the names of the DSOs so that they can be 
installed in parallel, maybe with configuration options to pass the 
version string, similar to the kernel.  This could for example allow us 
to implement recovery from broken glibcs without having to reach out for 
a rescue disk.

However I understand that it would be quite a pain to implement and it 
doesn't seem to be on anyone's TODO list, certainly not mine.  So I 
won't get in the way of this since it solves present day issues with 
library updates.  It would be interesting to hear from other 
distribution maintainers on what they think of the change.

Siddhesh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/4] Do not install shared objects under versioned names
  2021-06-14 14:49 ` Siddhesh Poyarekar
@ 2021-06-27 20:43   ` Carlos O'Donell
  2021-06-28  3:42     ` Siddhesh Poyarekar
  0 siblings, 1 reply; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 20:43 UTC (permalink / raw)
  To: Siddhesh Poyarekar, Florian Weimer, libc-alpha

On 6/14/21 10:49 AM, Siddhesh Poyarekar wrote:
> On 6/10/21 1:52 PM, Florian Weimer via Libc-alpha wrote:
>> This is essentially a repost of the “Add
>> --disable-major-minor-libraries configure option” series.  Joseph
>> suggested that the configure option is not needed, so this version
>> implements the change unconditionally.
>> 
>> Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two 
>> build-many-glibcs.py trees with and without these patches, using
>> this command to see if there are missing files besides the
>> versioned DSOs or any dangling symbolic links.
>> 
>> cd /home/bmg/install/glibcs && find -printf '%P\n' \ | while read x
>> ; do test -r /home/bmg-install-glibcs/$x || echo $x done \ | grep
>> -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'
>> 
>> /home/bmg/install/glibcs is the unpatched build, 
>> /home/bmg-install-glibcs is the build with the patches applied.
>> As expected, there was no output.
> 
> I was hoping that we would go in the opposite direction with this,
> i.e. encode a unique identifier in the names of the DSOs so that they
> can be installed in parallel, maybe with configuration options to
> pass the version string, similar to the kernel.  This could for
> example allow us to implement recovery from broken glibcs without
> having to reach out for a rescue disk.

I think this is never going to happen. I'll tell you why. At one point I
thought it *would* happen, and I thought we needed it, but two things
prevent it:

- Downstream QE teams rightly argue that changing libc has significant
  impact that much of the higher level stack testing needs to be redone.
  Consider the recent spat of seccomp/glibc, firefox/glibc, chrome/glibc
  issues all around "internal" implementation details that touch against
  the sandboxing.

- Containers. In the past we might have said "Yeah, we need 2 libcs for
  the sake of two distinct requirements." Today we just run processes in
  containers. The general concept of "multiple libraries" I think is
  going to disappear underneath the improving container tooling. Rather
  than 2 libcs installed, we'll have two assembled containers, each with
  a different libc.
 
> However I understand that it would be quite a pain to implement and
> it doesn't seem to be on anyone's TODO list, certainly not mine.  So
> I won't get in the way of this since it solves present day issues
> with library updates.  It would be interesting to hear from other
> distribution maintainers on what they think of the change.

I think Florian is moving this in the *right* direction e.g. simple,
robust, one file. Without a more compelling use case for multiple
libcs in one setup I think this is the right move.

-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/4] Do not install shared objects under versioned names
  2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
                   ` (5 preceding siblings ...)
  2021-06-14 14:49 ` Siddhesh Poyarekar
@ 2021-06-27 21:31 ` Carlos O'Donell
  6 siblings, 0 replies; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 21:31 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 4:22 AM, Florian Weimer via Libc-alpha wrote:
> This is essentially a repost of the “Add --disable-major-minor-libraries
> configure option” series.  Joseph suggested that the configure option is
> not needed, so this version implements the change unconditionally.

This is absolutely the right direction.

I like that we simplify the layout.

I have commented on Siddhesh's thoughts in the other thread, and I think
we are never likely to implement a solution that installs parallel libcs
given the QE and container aspects.

Therefore I'd like to see this move forward.
 
> Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two
> build-many-glibcs.py trees with and without these patches, using this
> command to see if there are missing files besides the versioned DSOs or
> any dangling symbolic links.
> 
> cd /home/bmg/install/glibcs && find -printf '%P\n' \
>   | while read x ; do
>     test -r /home/bmg-install-glibcs/$x || echo $x
>   done \
>   | grep -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'
> 
> /home/bmg/install/glibcs is the unpatched build,
> /home/bmg-install-glibcs is the build with the patches applied.  As
> expected, there was no output.
> 
> Thanks,
> Florian
> 
> Florian Weimer (4):
>   nptl_db: Install libthread_db under a regular implementation name
>   Makerules: Remove lib-version, $(subdir-version)
>   elf: Generalize name-based DSO recognition in ldconfig
>   Install shared objects under their ABI names
> 
>  INSTALL             | 10 +++++++
>  Makefile            |  6 ----
>  Makerules           | 67 +++++----------------------------------------
>  NEWS                |  8 ++++++
>  elf/Makefile        | 12 ++------
>  elf/dl-is_dso.h     | 33 ++++++++++++++++++++++
>  elf/ldconfig.c      |  5 ++--
>  elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++
>  nptl_db/Makefile    |  2 --
>  9 files changed, 98 insertions(+), 80 deletions(-)
>  create mode 100644 elf/dl-is_dso.h
>  create mode 100644 elf/tst-dl-is_dso.c
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name
  2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
@ 2021-06-27 21:32   ` Carlos O'Donell
  0 siblings, 0 replies; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 21:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 4:23 AM, Florian Weimer via Libc-alpha wrote:
> Currently, the name is always libthread_db-1.0.so.  It does not change
> with the glibc version, like the other libraries.

Correct.
 
> GDB hard-codes libthread_db.so.1 (the soname), so this change does not
> affect loading libthread_db.

Right.

No regressions on x86_64 or i686. Installed files look good.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> Tested on x86_64-linux-gnu, in an environment where the nptl GDB tests
> actually run.
> ---
>  nptl_db/Makefile | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/nptl_db/Makefile b/nptl_db/Makefile
> index ea721c1dcf..1f79c018a1 100644
> --- a/nptl_db/Makefile
> +++ b/nptl_db/Makefile
> @@ -21,8 +21,6 @@ subdir          := nptl_db
>  
>  include ../Makeconfig
>  
> -nptl_db-version = 1.0
> -
>  extra-libs = libthread_db
>  extra-libs-others := $(extra-libs)
>  
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version)
  2021-06-10  8:23 ` [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) Florian Weimer
@ 2021-06-27 21:32   ` Carlos O'Donell
  0 siblings, 0 replies; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 21:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 4:23 AM, Florian Weimer via Libc-alpha wrote:
> Also clarify that the “versioned” term refers to the soname, not the glibc
> version (which also ends up in the installed file name).

Right.

Tested on x86_64 and i686. No regressions. Installed files look good.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
 
> I verified on x86_64-linux-gnu that “make install” produces the same
> files.
> ---
>  Makerules | 26 ++++----------------------
>  1 file changed, 4 insertions(+), 22 deletions(-)
> 
> diff --git a/Makerules b/Makerules
> index ca9885436e..d3f29d0b89 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -982,22 +982,21 @@ install-lib.so := $(filter %.so,$(install-lib:%_pic.a=%.so))
>  install-lib := $(filter-out %.so %_pic.a,$(install-lib))
>  
>  ifeq (yes,$(build-shared))
> -# Find which .so's have versions.
> +# Find which .so's have a version number in their soname.

OK.

>  versioned := $(strip $(foreach so,$(install-lib.so),\
>  			       $(patsubst %,$(so),$($(so)-version))))
>  
>  install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
>  install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
>  
> -# For versioned libraries, we install three files:
> +# For libraries whose soname have version numbers, we install three files:

OK. Correct.

>  #	$(inst_libdir)/libfoo.so	-- for linking, symlink or ld script
>  #	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME, symlink
>  #	$(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
> -lib-version := $(firstword $($(subdir)-version) $(version))

OK. Remove.

>  install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
>  		      $(foreach L,$(install-lib.so-versioned),\
>  				$(inst_libdir)/$L \
> -				$(inst_slibdir)/$(L:.so=)-$(lib-version).so \
> +				$(inst_slibdir)/$(L:.so=)-$(version).so \

OK. This doesn't change anything. Cleanup.

>  				$(inst_slibdir)/$L$($L-version))
>  
>  # Install all the unversioned shared libraries.
> @@ -1125,7 +1124,6 @@ include $(o-iterator)
>  
>  generated += $(foreach o,$(versioned),$o$($o-version))
>  
> -ifeq (,$($(subdir)-version))

OK. Cleanup.

>  define o-iterator-doit
>  $(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
>  				 $(+force);
> @@ -1140,23 +1138,7 @@ $(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
>  endef
>  object-suffixes-left := $(versioned)
>  include $(o-iterator)
> -else
> -define o-iterator-doit
> -$(inst_slibdir)/$o$($o-version): \
> -  $(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so $(+force);
> -	$$(make-shlib-link)
> -endef
> -object-suffixes-left := $(versioned)
> -include $(o-iterator)
> -
> -define o-iterator-doit
> -$(inst_slibdir)/$(o:.so=)-$($(subdir)-version).so: $(objpfx)$o $(+force);
> -	$$(do-install-program)
> -endef
> -object-suffixes-left := $(versioned)
> -include $(o-iterator)
> -endif
> -endif
> +endif # ifneq (,$(versioned))

OK. Not needed.

>  
>  define do-install-so
>  $(do-install-program)
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig
  2021-06-10  8:23 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer
@ 2021-06-27 21:32   ` Carlos O'Donell
  0 siblings, 0 replies; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 21:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 4:23 AM, Florian Weimer via Libc-alpha wrote:
> This introduces <dl-is_dso.h> and the _dl_is_dso function.  A
> test ensures that the official names of libc.so, ld.so, and their
> versioned names are recognized.

LGTM.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  elf/Makefile        |  2 +-
>  elf/dl-is_dso.h     | 33 +++++++++++++++++++++++++++++++++
>  elf/ldconfig.c      |  5 ++---
>  elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++++++++++++++
>  4 files changed, 71 insertions(+), 4 deletions(-)
>  create mode 100644 elf/dl-is_dso.h
>  create mode 100644 elf/tst-dl-is_dso.c
> 
> diff --git a/elf/Makefile b/elf/Makefile
> index 5c47daee12..1751f5ec67 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -223,7 +223,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
>  	 tst-single_threaded tst-single_threaded-pthread \
>  	 tst-tls-ie tst-tls-ie-dlmopen argv0test \
>  	 tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \
> -	 tst-tls20 tst-tls21 tst-dlmopen-dlerror
> +	 tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dl-is_dso

OK.

>  #	 reldep9
>  tests-internal += loadtest unload unload2 circleload1 \
>  	 neededtest neededtest2 neededtest3 neededtest4 \
> diff --git a/elf/dl-is_dso.h b/elf/dl-is_dso.h
> new file mode 100644
> index 0000000000..94e00966a1
> --- /dev/null
> +++ b/elf/dl-is_dso.h
> @@ -0,0 +1,33 @@
> +/* Heuristic for recognizing DSO file names.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <stdbool.h>
> +#include <string.h>
> +
> +/* Returns true if the file name looks like a DSO name.  */
> +static bool
> +_dl_is_dso (const char *name)
> +{
> +  /* Recognize lib*.so*, ld-*.so*, ld.so.*, ld64.so.*.  ld-*.so*
> +     matches both platform dynamic linker names like ld-linux.so.2,
> +     and versioned dynamic loader names like ld-2.12.so.  */
> +  return (((strncmp (name, "lib", 3) == 0 || strncmp (name, "ld-", 3) == 0)
> +           && strstr (name, ".so") != NULL)
> +          || strncmp (name, "ld.so.", 6) == 0
> +          || strncmp (name, "ld64.so.", 8) == 0);

OK. Refactor and change. This expands the definition a bit, but it should
still be correct to capture the wider set of names.

> +}
> diff --git a/elf/ldconfig.c b/elf/ldconfig.c
> index 96bf7700b2..1037e8d0cf 100644
> --- a/elf/ldconfig.c
> +++ b/elf/ldconfig.c
> @@ -43,6 +43,7 @@
>  #include <ldconfig.h>
>  #include <dl-cache.h>
>  #include <dl-hwcaps.h>
> +#include <dl-is_dso.h>

OK.

>  
>  #include <dl-procinfo.h>
>  
> @@ -842,9 +843,7 @@ search_dir (const struct dir_entry *entry)
>  	 subdirectory (if not already processing a glibc-hwcaps
>  	 subdirectory)?  The dynamic linker is also considered as
>  	 shared library.  */
> -      if (((strncmp (direntry->d_name, "lib", 3) != 0
> -	    && strncmp (direntry->d_name, "ld-", 3) != 0)
> -	   || strstr (direntry->d_name, ".so") == NULL)
> +      if (!_dl_is_dso (direntry->d_name)

OK.

>  	  && (direntry->d_type == DT_REG
>  	      || (entry->hwcaps == NULL
>  		  && !is_hwcap_platform (direntry->d_name))))
> diff --git a/elf/tst-dl-is_dso.c b/elf/tst-dl-is_dso.c
> new file mode 100644
> index 0000000000..48d2cc9fbe
> --- /dev/null
> +++ b/elf/tst-dl-is_dso.c
> @@ -0,0 +1,35 @@
> +/* Test heuristic for recognizing DSO file names.
> +   Copyright (C) 2021 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <https://www.gnu.org/licenses/>.  */
> +
> +#include <dl-is_dso.h>
> +#include <gnu/lib-names.h>
> +#include <support/check.h>
> +
> +static int
> +do_test (void)
> +{
> +  /* Official ABI names.  */
> +  TEST_VERIFY (_dl_is_dso (LIBC_SO));
> +  TEST_VERIFY (_dl_is_dso (LD_SO));

OK.

> +  /* Version-based names.  The version number does not matter.  */
> +  TEST_VERIFY (_dl_is_dso ("libc-2.12.so"));
> +  TEST_VERIFY (_dl_is_dso ("ld-2.12.so"));

OK.

> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/4] Install shared objects under their ABI names
  2021-06-10  8:23 ` [PATCH 4/4] Install shared objects under their ABI names Florian Weimer
@ 2021-06-27 21:32   ` Carlos O'Donell
  0 siblings, 0 replies; 15+ messages in thread
From: Carlos O'Donell @ 2021-06-27 21:32 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 6/10/21 4:23 AM, Florian Weimer via Libc-alpha wrote:
> Previously, the installed objects were named like libc-2.33.so,
> and the ABI soname libc.so.6 was just a symbolic link.

This patch contains INSTALL changes which should not be here and I expect
were left over from your previous patch. Please drop them. Because you 
are *only* dropping the edits to that file you can commit as-is without
a v2. So I'm providing a review here.
 
> The Makefile targets to install these symbolic links are no longer
> needed after this, so they are removed with this commit.  The more
> general $(make-link) command (which invokes scripts/rellns-sh) is
> retained because other symbolic links are still needed.

No regressions on x86_64 and i686. Installed files look good.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@rehdat.com>

> ---
>  INSTALL      | 10 ++++++++++

Drop this.

>  Makefile     |  6 ------
>  Makerules    | 45 +++++----------------------------------------
>  NEWS         |  8 ++++++++
>  elf/Makefile | 10 ++--------
>  5 files changed, 25 insertions(+), 54 deletions(-)
> 
> diff --git a/INSTALL b/INSTALL
> index bc761ab98b..ed5f66489b 100644
> --- a/INSTALL
> +++ b/INSTALL

Drop this change from this file.

> @@ -199,6 +199,16 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
>       RELRO and a read-only global offset table (GOT), at the cost of
>       slightly increased program load times.
>  
> +'--disable-major-minor-libraries'
> +     Do not install shared objects under file names that contain the
> +     major and minor version of the GNU C Library.  By default, such
> +     names are used, and the names defined by the ABI are provided as
> +     symbolic links only.  This causes problems with certain package
> +     managers during library upgrades and (in particular) downgrades, so
> +     this option can be used to install these shared objects directly
> +     under their ABI-defined names, without an additional indirection
> +     via symbolic links.
> +
>  '--enable-pt_chown'
>       The file 'pt_chown' is a helper binary for 'grantpt' (*note
>       Pseudo-Terminals: Allocation.) that is installed setuid root to fix
> diff --git a/Makefile b/Makefile
> index 242d36de91..c115c652a0 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -109,12 +109,6 @@ elf/ldso_install:
>  # Ignore the error if we cannot update /etc/ld.so.cache.
>  ifeq (no,$(cross-compiling))
>  ifeq (yes,$(build-shared))
> -install: install-symbolic-link
> -.PHONY: install-symbolic-link
> -install-symbolic-link: subdir_install
> -	$(symbolic-link-prog) $(symbolic-link-list)
> -	rm -f $(symbolic-link-list)
> -

OK.

>  install:
>  	-test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
>  	  $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
> diff --git a/Makerules b/Makerules
> index d3f29d0b89..6efff78fbe 100644
> --- a/Makerules
> +++ b/Makerules
> @@ -989,14 +989,12 @@ versioned := $(strip $(foreach so,$(install-lib.so),\
>  install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
>  install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
>  
> -# For libraries whose soname have version numbers, we install three files:
> +# For libraries whose soname have version numbers, we install two files:

OK.

>  #	$(inst_libdir)/libfoo.so	-- for linking, symlink or ld script
> -#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME, symlink
> -#	$(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
> +#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME

OK.

>  install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
>  		      $(foreach L,$(install-lib.so-versioned),\
>  				$(inst_libdir)/$L \
> -				$(inst_slibdir)/$(L:.so=)-$(version).so \

OK.

>  				$(inst_slibdir)/$L$($L-version))
>  
>  # Install all the unversioned shared libraries.
> @@ -1029,35 +1027,10 @@ ln -f $(objpfx)/$(@F) $@
>  endef
>  endif
>  
> -ifeq (yes,$(build-shared))
> -ifeq (no,$(cross-compiling))
> -symbolic-link-prog := $(elf-objpfx)sln
> -symbolic-link-list := $(elf-objpfx)symlink.list
> -define make-shlib-link
> -echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
> -endef
> -else # cross-compiling
> -# We need a definition that can be used by elf/Makefile's install rules.
> -symbolic-link-prog = $(LN_S)
> -endif
> -endif
> -ifndef make-shlib-link
> -define make-shlib-link
> -rm -f $@
> -$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
> -endef
> -endif

OK.

> -
>  ifdef libc.so-version
> -# For a library specified to be version N, install three files:
> -# libc.so	->	libc.so.N	(e.g. libc.so.6)
> -# libc.so.6	->	libc-VERSION.so	(e.g. libc-1.10.so)
> -
> -$(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
> -					   $(+force)
> -	$(make-shlib-link)
> -$(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)

OK.

> +$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
>  	$(do-install-program)
> +
>  install: $(inst_slibdir)/libc.so$(libc.so-version)
>  
>  # This fragment of linker script gives the OUTPUT_FORMAT statement
> @@ -1125,15 +1098,7 @@ include $(o-iterator)
>  generated += $(foreach o,$(versioned),$o$($o-version))
>  
>  define o-iterator-doit
> -$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
> -				 $(+force);
> -	$$(make-shlib-link)
> -endef
> -object-suffixes-left := $(versioned)
> -include $(o-iterator)
> -
> -define o-iterator-doit
> -$(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
> +$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
>  	$$(do-install-program)

OK.

>  endef
>  object-suffixes-left := $(versioned)
> diff --git a/NEWS b/NEWS
> index 1bf3daa502..1634e20ce5 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -48,6 +48,14 @@ Deprecated and removed features, and other changes affecting compatibility:
>  * The function pthread_yield has been deprecated; programs should use
>    the equivalent standard function sched_yield instead.
>  
> +* Previously, glibc installed its various shared objects under versioned
> +  file names such as libc-2.33.so.  The ABI sonames (e.g., libc.so.6)
> +  were provided as symbolic links.  Starting with glibc 2.34, the shared
> +  objects are installed under their ABI sonames directly, without
> +  symbolic links.  This increases compatibility with distribution
> +  package managers that delete removed files late during the package
> +  upgrade or downgrade process.

OK. I agree, the new glibc is present immediately at unpack time with a scheme
that keeps the new glibc always as libc.so.6. It is simpler and easier to
reason about when it comes to package management.

> +
>  Changes to build and runtime requirements:
>  
>  * On Linux, the shm_open, sem_open, and related functions now expect the
> diff --git a/elf/Makefile b/elf/Makefile
> index 1751f5ec67..02f634c192 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -628,20 +628,14 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
>  CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
>  
>  ifeq (yes,$(build-shared))
> -$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
> +$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force)

OK.

>  	$(make-target-directory)
>  	$(do-install-program)
>  
> -$(inst_rtlddir)/$(rtld-installed-name): \
> -  $(inst_slibdir)/$(rtld-version-installed-name) \
> -  $(inst_slibdir)/libc-$(version).so
> -	$(make-target-directory)
> -	$(make-shlib-link)
> -

OK.

>  # Special target called by parent to install just the dynamic linker.
>  .PHONY: ldso_install
>  ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
> -endif
> +endif # $(build-shared)
>  
>  
>  # Workarounds for ${exec_prefix} expansion in configure variables.
> 


-- 
Cheers,
Carlos.


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/4] Do not install shared objects under versioned names
  2021-06-27 20:43   ` Carlos O'Donell
@ 2021-06-28  3:42     ` Siddhesh Poyarekar
  0 siblings, 0 replies; 15+ messages in thread
From: Siddhesh Poyarekar @ 2021-06-28  3:42 UTC (permalink / raw)
  To: Carlos O'Donell, Florian Weimer, libc-alpha

On 6/28/21 2:13 AM, Carlos O'Donell wrote:
> I think this is never going to happen. I'll tell you why. At one point I
> thought it *would* happen, and I thought we needed it, but two things
> prevent it:
> 
> - Downstream QE teams rightly argue that changing libc has significant
>    impact that much of the higher level stack testing needs to be redone.
>    Consider the recent spat of seccomp/glibc, firefox/glibc, chrome/glibc
>    issues all around "internal" implementation details that touch against
>    the sandboxing.
> 
> - Containers. In the past we might have said "Yeah, we need 2 libcs for
>    the sake of two distinct requirements." Today we just run processes in
>    containers. The general concept of "multiple libraries" I think is
>    going to disappear underneath the improving container tooling. Rather
>    than 2 libcs installed, we'll have two assembled containers, each with
>    a different libc.

I'm much less concerned about multiple system glibc versions being use 
in tandem; that may even be harmful.  My concern is recovery.  I agree 
that in practice recovery is much less of a common problem; I've managed 
to brick Fedora glibc only once (ok maybe twice) in my lifetime.  So 
maybe I'm overthinking it.

> I think Florian is moving this in the *right* direction e.g. simple,
> robust, one file. Without a more compelling use case for multiple
> libcs in one setup I think this is the right move.

I agree that if there's no way to usefully utilize the version numbers 
then it's a step forward to drop them.

Siddhesh

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig
  2021-06-09 11:15 [PATCH 0/4] Add --disable-major-minor-libraries configure option Florian Weimer
@ 2021-06-09 11:16 ` Florian Weimer
  0 siblings, 0 replies; 15+ messages in thread
From: Florian Weimer @ 2021-06-09 11:16 UTC (permalink / raw)
  To: libc-alpha

This introduces <dl-is_dso.h> and the _dl_is_dso function.  A
test ensures that the official names of libc.so, ld.so, and their
versioned names are recognized.
---
 elf/Makefile        |  2 +-
 elf/dl-is_dso.h     | 33 +++++++++++++++++++++++++++++++++
 elf/ldconfig.c      |  5 ++---
 elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 71 insertions(+), 4 deletions(-)
 create mode 100644 elf/dl-is_dso.h
 create mode 100644 elf/tst-dl-is_dso.c

diff --git a/elf/Makefile b/elf/Makefile
index e9788d3d4f..5389c35536 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -223,7 +223,7 @@ tests += restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-single_threaded tst-single_threaded-pthread \
 	 tst-tls-ie tst-tls-ie-dlmopen argv0test \
 	 tst-glibc-hwcaps tst-glibc-hwcaps-prepend tst-glibc-hwcaps-mask \
-	 tst-tls20 tst-tls21 tst-dlmopen-dlerror
+	 tst-tls20 tst-tls21 tst-dlmopen-dlerror tst-dl-is_dso
 #	 reldep9
 tests-internal += loadtest unload unload2 circleload1 \
 	 neededtest neededtest2 neededtest3 neededtest4 \
diff --git a/elf/dl-is_dso.h b/elf/dl-is_dso.h
new file mode 100644
index 0000000000..94e00966a1
--- /dev/null
+++ b/elf/dl-is_dso.h
@@ -0,0 +1,33 @@
+/* Heuristic for recognizing DSO file names.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdbool.h>
+#include <string.h>
+
+/* Returns true if the file name looks like a DSO name.  */
+static bool
+_dl_is_dso (const char *name)
+{
+  /* Recognize lib*.so*, ld-*.so*, ld.so.*, ld64.so.*.  ld-*.so*
+     matches both platform dynamic linker names like ld-linux.so.2,
+     and versioned dynamic loader names like ld-2.12.so.  */
+  return (((strncmp (name, "lib", 3) == 0 || strncmp (name, "ld-", 3) == 0)
+           && strstr (name, ".so") != NULL)
+          || strncmp (name, "ld.so.", 6) == 0
+          || strncmp (name, "ld64.so.", 8) == 0);
+}
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 96bf7700b2..1037e8d0cf 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -43,6 +43,7 @@
 #include <ldconfig.h>
 #include <dl-cache.h>
 #include <dl-hwcaps.h>
+#include <dl-is_dso.h>
 
 #include <dl-procinfo.h>
 
@@ -842,9 +843,7 @@ search_dir (const struct dir_entry *entry)
 	 subdirectory (if not already processing a glibc-hwcaps
 	 subdirectory)?  The dynamic linker is also considered as
 	 shared library.  */
-      if (((strncmp (direntry->d_name, "lib", 3) != 0
-	    && strncmp (direntry->d_name, "ld-", 3) != 0)
-	   || strstr (direntry->d_name, ".so") == NULL)
+      if (!_dl_is_dso (direntry->d_name)
 	  && (direntry->d_type == DT_REG
 	      || (entry->hwcaps == NULL
 		  && !is_hwcap_platform (direntry->d_name))))
diff --git a/elf/tst-dl-is_dso.c b/elf/tst-dl-is_dso.c
new file mode 100644
index 0000000000..48d2cc9fbe
--- /dev/null
+++ b/elf/tst-dl-is_dso.c
@@ -0,0 +1,35 @@
+/* Test heuristic for recognizing DSO file names.
+   Copyright (C) 2021 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <dl-is_dso.h>
+#include <gnu/lib-names.h>
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  /* Official ABI names.  */
+  TEST_VERIFY (_dl_is_dso (LIBC_SO));
+  TEST_VERIFY (_dl_is_dso (LD_SO));
+  /* Version-based names.  The version number does not matter.  */
+  TEST_VERIFY (_dl_is_dso ("libc-2.12.so"));
+  TEST_VERIFY (_dl_is_dso ("ld-2.12.so"));
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.31.1



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-06-28  3:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 4/4] Install shared objects under their ABI names Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-14 11:04 ` [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
2021-06-14 14:49 ` Siddhesh Poyarekar
2021-06-27 20:43   ` Carlos O'Donell
2021-06-28  3:42     ` Siddhesh Poyarekar
2021-06-27 21:31 ` Carlos O'Donell
  -- strict thread matches above, loose matches on Subject: below --
2021-06-09 11:15 [PATCH 0/4] Add --disable-major-minor-libraries configure option Florian Weimer
2021-06-09 11:16 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).