fd5c07b
Patch series proposed upstream:
fd5c07b
fd5c07b
  <https://sourceware.org/pipermail/libc-alpha/2021-June/127473.html>
fd5c07b
fd5c07b
Author: Florian Weimer <fweimer@redhat.com>
fd5c07b
Date:   Wed Jun 9 14:12:46 2021 +0200
fd5c07b
fd5c07b
    Install shared objects under their ABI names
fd5c07b
    
fd5c07b
    Previously, the installed objects were named like libc-2.33.so,
fd5c07b
    and the ABI soname libc.so.6 was just a symbolic link.
fd5c07b
    
fd5c07b
    The Makefile targets to install these symbolic links are no longer
fd5c07b
    needed after this, so they are removed with this commit.  The more
fd5c07b
    general $(make-link) command (which invokes scripts/rellns-sh) is
fd5c07b
    retained because other symbolic links are still needed.
fd5c07b
fd5c07b
diff --git a/INSTALL b/INSTALL
fd5c07b
index 56ed01d4386ad8b7..7f054f422d990d8a 100644
fd5c07b
--- a/INSTALL
fd5c07b
+++ b/INSTALL
fd5c07b
@@ -199,6 +199,16 @@ if 'CFLAGS' is specified it must enable optimization.  For example:
fd5c07b
      RELRO and a read-only global offset table (GOT), at the cost of
fd5c07b
      slightly increased program load times.
fd5c07b
 
fd5c07b
+'--disable-major-minor-libraries'
fd5c07b
+     Do not install shared objects under file names that contain the
fd5c07b
+     major and minor version of the GNU C Library.  By default, such
fd5c07b
+     names are used, and the names defined by the ABI are provided as
fd5c07b
+     symbolic links only.  This causes problems with certain package
fd5c07b
+     managers during library upgrades and (in particular) downgrades, so
fd5c07b
+     this option can be used to install these shared objects directly
fd5c07b
+     under their ABI-defined names, without an additional indirection
fd5c07b
+     via symbolic links.
fd5c07b
+
fd5c07b
 '--enable-pt_chown'
fd5c07b
      The file 'pt_chown' is a helper binary for 'grantpt' (*note
fd5c07b
      Pseudo-Terminals: Allocation.) that is installed setuid root to fix
fd5c07b
diff --git a/Makefile b/Makefile
fd5c07b
index 242d36de914c516f..c115c652a0b8c1ce 100644
fd5c07b
--- a/Makefile
fd5c07b
+++ b/Makefile
fd5c07b
@@ -109,12 +109,6 @@ elf/ldso_install:
fd5c07b
 # Ignore the error if we cannot update /etc/ld.so.cache.
fd5c07b
 ifeq (no,$(cross-compiling))
fd5c07b
 ifeq (yes,$(build-shared))
fd5c07b
-install: install-symbolic-link
fd5c07b
-.PHONY: install-symbolic-link
fd5c07b
-install-symbolic-link: subdir_install
fd5c07b
-	$(symbolic-link-prog) $(symbolic-link-list)
fd5c07b
-	rm -f $(symbolic-link-list)
fd5c07b
-
fd5c07b
 install:
fd5c07b
 	-test ! -x $(elf-objpfx)ldconfig || LC_ALL=C \
fd5c07b
 	  $(elf-objpfx)ldconfig $(addprefix -r ,$(install_root)) \
fd5c07b
diff --git a/Makerules b/Makerules
fd5c07b
index d3f29d0b8991efc7..6efff78fbe44bdca 100644
fd5c07b
--- a/Makerules
fd5c07b
+++ b/Makerules
fd5c07b
@@ -989,14 +989,12 @@ versioned := $(strip $(foreach so,$(install-lib.so),\
fd5c07b
 install-lib.so-versioned := $(filter $(versioned), $(install-lib.so))
fd5c07b
 install-lib.so-unversioned := $(filter-out $(versioned), $(install-lib.so))
fd5c07b
 
fd5c07b
-# For libraries whose soname have version numbers, we install three files:
fd5c07b
+# For libraries whose soname have version numbers, we install two files:
fd5c07b
 #	$(inst_libdir)/libfoo.so	-- for linking, symlink or ld script
fd5c07b
-#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME, symlink
fd5c07b
-#	$(inst_slibdir)/libfoo-X.Y.Z.so -- the real shared object file
fd5c07b
+#	$(inst_slibdir)/libfoo.so.NN	-- for loading by SONAME
fd5c07b
 install-lib-nosubdir: $(install-lib.so-unversioned:%=$(inst_slibdir)/%) \
fd5c07b
 		      $(foreach L,$(install-lib.so-versioned),\
fd5c07b
 				$(inst_libdir)/$L \
fd5c07b
-				$(inst_slibdir)/$(L:.so=)-$(version).so \
fd5c07b
 				$(inst_slibdir)/$L$($L-version))
fd5c07b
 
fd5c07b
 # Install all the unversioned shared libraries.
fd5c07b
@@ -1029,35 +1027,10 @@ ln -f $(objpfx)/$(@F) $@
fd5c07b
 endef
fd5c07b
 endif
fd5c07b
 
fd5c07b
-ifeq (yes,$(build-shared))
fd5c07b
-ifeq (no,$(cross-compiling))
fd5c07b
-symbolic-link-prog := $(elf-objpfx)sln
fd5c07b
-symbolic-link-list := $(elf-objpfx)symlink.list
fd5c07b
-define make-shlib-link
fd5c07b
-echo `$(..)scripts/rellns-sh -p $< $@` $@ >> $(symbolic-link-list)
fd5c07b
-endef
fd5c07b
-else # cross-compiling
fd5c07b
-# We need a definition that can be used by elf/Makefile's install rules.
fd5c07b
-symbolic-link-prog = $(LN_S)
fd5c07b
-endif
fd5c07b
-endif
fd5c07b
-ifndef make-shlib-link
fd5c07b
-define make-shlib-link
fd5c07b
-rm -f $@
fd5c07b
-$(LN_S) `$(..)scripts/rellns-sh -p $< $@` $@
fd5c07b
-endef
fd5c07b
-endif
fd5c07b
-
fd5c07b
 ifdef libc.so-version
fd5c07b
-# For a library specified to be version N, install three files:
fd5c07b
-# libc.so	->	libc.so.N	(e.g. libc.so.6)
fd5c07b
-# libc.so.6	->	libc-VERSION.so	(e.g. libc-1.10.so)
fd5c07b
-
fd5c07b
-$(inst_slibdir)/libc.so$(libc.so-version): $(inst_slibdir)/libc-$(version).so \
fd5c07b
-					   $(+force)
fd5c07b
-	$(make-shlib-link)
fd5c07b
-$(inst_slibdir)/libc-$(version).so: $(common-objpfx)libc.so $(+force)
fd5c07b
+$(inst_slibdir)/libc.so$(libc.so-version): $(common-objpfx)libc.so $(+force)
fd5c07b
 	$(do-install-program)
fd5c07b
+
fd5c07b
 install: $(inst_slibdir)/libc.so$(libc.so-version)
fd5c07b
 
fd5c07b
 # This fragment of linker script gives the OUTPUT_FORMAT statement
fd5c07b
@@ -1125,15 +1098,7 @@ include $(o-iterator)
fd5c07b
 generated += $(foreach o,$(versioned),$o$($o-version))
fd5c07b
 
fd5c07b
 define o-iterator-doit
fd5c07b
-$(inst_slibdir)/$o$($o-version): $(inst_slibdir)/$(o:.so=)-$(version).so \
fd5c07b
-				 $(+force);
fd5c07b
-	$$(make-shlib-link)
fd5c07b
-endef
fd5c07b
-object-suffixes-left := $(versioned)
fd5c07b
-include $(o-iterator)
fd5c07b
-
fd5c07b
-define o-iterator-doit
fd5c07b
-$(inst_slibdir)/$(o:.so=)-$(version).so: $(objpfx)$o $(+force);
fd5c07b
+$(inst_slibdir)/$o$($o-version): $(objpfx)$o $(+force);
fd5c07b
 	$$(do-install-program)
fd5c07b
 endef
fd5c07b
 object-suffixes-left := $(versioned)
fd5c07b
diff --git a/elf/Makefile b/elf/Makefile
fd5c07b
index 1751f5ec6772eceb..02f634c19241949f 100644
fd5c07b
--- a/elf/Makefile
fd5c07b
+++ b/elf/Makefile
fd5c07b
@@ -628,20 +628,14 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
fd5c07b
 CPPFLAGS-dl-load.c += -I$(objpfx). -I$(csu-objpfx).
fd5c07b
 
fd5c07b
 ifeq (yes,$(build-shared))
fd5c07b
-$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
fd5c07b
+$(inst_rtlddir)/$(rtld-installed-name): $(objpfx)ld.so $(+force)
fd5c07b
 	$(make-target-directory)
fd5c07b
 	$(do-install-program)
fd5c07b
 
fd5c07b
-$(inst_rtlddir)/$(rtld-installed-name): \
fd5c07b
-  $(inst_slibdir)/$(rtld-version-installed-name) \
fd5c07b
-  $(inst_slibdir)/libc-$(version).so
fd5c07b
-	$(make-target-directory)
fd5c07b
-	$(make-shlib-link)
fd5c07b
-
fd5c07b
 # Special target called by parent to install just the dynamic linker.
fd5c07b
 .PHONY: ldso_install
fd5c07b
 ldso_install: $(inst_rtlddir)/$(rtld-installed-name)
fd5c07b
-endif
fd5c07b
+endif # $(build-shared)
fd5c07b
 
fd5c07b
 
fd5c07b
 # Workarounds for ${exec_prefix} expansion in configure variables.