about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/glibc
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
committerAlyssa Ross <hi@alyssa.is>2023-06-16 06:56:35 +0000
commit99fcaeccb89621dd492203ce1f2d551c06f228ed (patch)
tree41cb730ae07383004789779b0f6e11cb3f4642a3 /nixpkgs/pkgs/development/libraries/glibc
parent59c5f5ac8682acc13bb22bc29c7cf02f7d75f01f (diff)
parent75a5ebf473cd60148ba9aec0d219f72e5cf52519 (diff)
downloadnixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.gz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.bz2
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.lz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.xz
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.tar.zst
nixlib-99fcaeccb89621dd492203ce1f2d551c06f228ed.zip
Merge branch 'nixos-unstable' of https://github.com/NixOS/nixpkgs
Conflicts:
	nixpkgs/nixos/modules/config/console.nix
	nixpkgs/nixos/modules/services/mail/mailman.nix
	nixpkgs/nixos/modules/services/mail/public-inbox.nix
	nixpkgs/nixos/modules/services/mail/rss2email.nix
	nixpkgs/nixos/modules/services/networking/ssh/sshd.nix
	nixpkgs/pkgs/applications/networking/instant-messengers/dino/default.nix
	nixpkgs/pkgs/applications/networking/irc/weechat/default.nix
	nixpkgs/pkgs/applications/window-managers/sway/default.nix
	nixpkgs/pkgs/build-support/go/module.nix
	nixpkgs/pkgs/build-support/rust/build-rust-package/default.nix
	nixpkgs/pkgs/development/interpreters/python/default.nix
	nixpkgs/pkgs/development/node-packages/overrides.nix
	nixpkgs/pkgs/development/tools/b4/default.nix
	nixpkgs/pkgs/servers/dict/dictd-db.nix
	nixpkgs/pkgs/servers/mail/public-inbox/default.nix
	nixpkgs/pkgs/tools/security/pinentry/default.nix
	nixpkgs/pkgs/tools/text/unoconv/default.nix
	nixpkgs/pkgs/top-level/all-packages.nix
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glibc')
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch39
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/2.35-master.patch.gzbin230755 -> 0 bytes
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/2.37-master.patch.gzbin0 -> 9447 bytes
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch39
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/common.nix82
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/default.nix113
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh1
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/locales.nix26
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/multi.nix13
-rw-r--r--nixpkgs/pkgs/development/libraries/glibc/reenable_DT_HASH.patch145
10 files changed, 286 insertions, 172 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch b/nixpkgs/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
index b2c998aabbef..b7658b59fb1e 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
+++ b/nixpkgs/pkgs/development/libraries/glibc/0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
@@ -1,4 +1,4 @@
-From faeeb0f353f5540da2015a41cb60fe43d199a1ac Mon Sep 17 00:00:00 2001
+From cdd0c4b168fe228de97778556cea5c0f936e0e79 Mon Sep 17 00:00:00 2001
 From: Bernardo Meurer <bernardo@meurer.org>
 Date: Fri, 22 Jul 2022 22:11:07 -0700
 Subject: [PATCH] Revert "Remove all usage of @BASH@ or ${BASH} in installed
@@ -22,10 +22,10 @@ Co-authored-by: Maximilian Bosch <maximilian@mbosch.me>
  8 files changed, 15 insertions(+), 10 deletions(-)
 
 diff --git a/debug/Makefile b/debug/Makefile
-index 96029f32ee..cbbdeda277 100644
+index 52f9a7852c..22e4ae5461 100644
 --- a/debug/Makefile
 +++ b/debug/Makefile
-@@ -238,7 +238,8 @@ $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
+@@ -265,8 +265,9 @@ $(objpfx)pcprofiledump: $(objpfx)pcprofiledump.o
  
  $(objpfx)xtrace: xtrace.sh
  	rm -f $@.new
@@ -36,21 +36,22 @@ index 96029f32ee..cbbdeda277 100644
 +	    -e 's|@PKGVERSION@|$(PKGVERSION)|' \
  	    -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|' $^ > $@.new \
  	&& rm -f $@ && mv $@.new $@ && chmod +x $@
+ 
 diff --git a/debug/xtrace.sh b/debug/xtrace.sh
-index 8c56e01449..c760391a33 100755
+index 3d1f2af43a..eb2ba7ad4a 100755
 --- a/debug/xtrace.sh
 +++ b/debug/xtrace.sh
 @@ -1,4 +1,4 @@
 -#!/bin/bash
 +#! @BASH@
- # Copyright (C) 1999-2022 Free Software Foundation, Inc.
+ # Copyright (C) 1999-2023 Free Software Foundation, Inc.
  # This file is part of the GNU C Library.
  
 diff --git a/elf/Makefile b/elf/Makefile
-index 3536b6af5e..83521d9dbc 100644
+index 0d19964d42..ee8ee1cd41 100644
 --- a/elf/Makefile
 +++ b/elf/Makefile
-@@ -256,7 +256,8 @@ $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
+@@ -250,7 +250,8 @@ $(objpfx)sotruss-lib.so: $(common-objpfx)libc.so $(objpfx)ld.so \
  	$(common-objpfx)libc_nonshared.a
  
  $(objpfx)sotruss: sotruss.sh $(common-objpfx)config.make
@@ -60,7 +61,7 @@ index 3536b6af5e..83521d9dbc 100644
  	    -e 's%@TEXTDOMAINDIR@%$(localedir)%g' \
  	    -e 's%@PREFIX@%$(prefix)%g' \
  	    -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
-@@ -1363,6 +1364,7 @@ ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
+@@ -1396,6 +1397,7 @@ ldd-rewrite = -e 's%@RTLD@%$(rtlddir)/$(rtld-installed-name)%g' \
  	      -e 's%@VERSION@%$(version)%g' \
  	      -e 's|@PKGVERSION@|$(PKGVERSION)|g' \
  	      -e 's|@REPORT_BUGS_TO@|$(REPORT_BUGS_TO)|g' \
@@ -69,30 +70,30 @@ index 3536b6af5e..83521d9dbc 100644
  
  ifeq ($(ldd-rewrite-script),no)
 diff --git a/elf/ldd.bash.in b/elf/ldd.bash.in
-index 3253b32ef8..127eb59206 100644
+index e45dec5894..e09428506e 100644
 --- a/elf/ldd.bash.in
 +++ b/elf/ldd.bash.in
 @@ -1,4 +1,4 @@
 -#!/bin/bash
 +#! @BASH@
- # Copyright (C) 1996-2022 Free Software Foundation, Inc.
+ # Copyright (C) 1996-2023 Free Software Foundation, Inc.
  # This file is part of the GNU C Library.
  
 diff --git a/elf/sotruss.sh b/elf/sotruss.sh
-index 22327eac5c..7d15bf4fc8 100755
+index 874a6bed3f..7cc154561e 100755
 --- a/elf/sotruss.sh
 +++ b/elf/sotruss.sh
 @@ -1,4 +1,4 @@
 -#!/bin/bash
 +#! @BASH@
- # Copyright (C) 2011-2022 Free Software Foundation, Inc.
+ # Copyright (C) 2011-2023 Free Software Foundation, Inc.
  # This file is part of the GNU C Library.
  
 diff --git a/malloc/Makefile b/malloc/Makefile
-index 2329cf718a..5d7de4bee7 100644
+index dfb51d344c..574b5e9579 100644
 --- a/malloc/Makefile
 +++ b/malloc/Makefile
-@@ -307,8 +307,9 @@ $(objpfx)mtrace: mtrace.pl
+@@ -306,8 +306,9 @@ $(objpfx)mtrace: mtrace.pl
  
  $(objpfx)memusage: memusage.sh
  	rm -f $@.new
@@ -105,20 +106,20 @@ index 2329cf718a..5d7de4bee7 100644
  	&& rm -f $@ && mv $@.new $@ && chmod +x $@
  
 diff --git a/malloc/memusage.sh b/malloc/memusage.sh
-index f447160b7d..faa4936639 100755
+index b1f5848b74..329e36ef8a 100755
 --- a/malloc/memusage.sh
 +++ b/malloc/memusage.sh
 @@ -1,4 +1,4 @@
 -#!/bin/bash
 +#! @BASH@
- # Copyright (C) 1999-2022 Free Software Foundation, Inc.
+ # Copyright (C) 1999-2023 Free Software Foundation, Inc.
  # This file is part of the GNU C Library.
  
 diff --git a/timezone/Makefile b/timezone/Makefile
-index a789c22d26..d65bdf2391 100644
+index 0306c0bca9..de9bbcc815 100644
 --- a/timezone/Makefile
 +++ b/timezone/Makefile
-@@ -130,7 +130,8 @@ $(testdata)/XT5: testdata/gen-XT5.sh
+@@ -132,7 +132,8 @@ $(testdata)/XT5: testdata/gen-XT5.sh
  	mv $@.tmp $@
  
  $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
@@ -129,5 +130,5 @@ index a789c22d26..d65bdf2391 100644
  	    -e '/PKGVERSION=/s|=.*|="$(PKGVERSION)"|' \
  	    -e '/REPORT_BUGS_TO=/s|=.*|="$(REPORT_BUGS_TO)"|' \
 -- 
-2.37.0
+2.38.4
 
diff --git a/nixpkgs/pkgs/development/libraries/glibc/2.35-master.patch.gz b/nixpkgs/pkgs/development/libraries/glibc/2.35-master.patch.gz
deleted file mode 100644
index 24939e1c0899..000000000000
--- a/nixpkgs/pkgs/development/libraries/glibc/2.35-master.patch.gz
+++ /dev/null
Binary files differdiff --git a/nixpkgs/pkgs/development/libraries/glibc/2.37-master.patch.gz b/nixpkgs/pkgs/development/libraries/glibc/2.37-master.patch.gz
new file mode 100644
index 000000000000..04b4e264751e
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/glibc/2.37-master.patch.gz
Binary files differdiff --git a/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch b/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch
deleted file mode 100644
index ce18b874c427..000000000000
--- a/nixpkgs/pkgs/development/libraries/glibc/allow-kernel-2.6.32.patch
+++ /dev/null
@@ -1,39 +0,0 @@
-diff --git a/sysdeps/unix/sysv/linux/configure b/sysdeps/unix/sysv/linux/configure
-index cace758c01..38fe7fe0b0 100644
---- a/sysdeps/unix/sysv/linux/configure
-+++ b/sysdeps/unix/sysv/linux/configure
-@@ -69,7 +69,7 @@ fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel header at least $minimum_kernel" >&5
- $as_echo_n "checking for kernel header at least $minimum_kernel... " >&6; }
- decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
--abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
-+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
- /* end confdefs.h.  */
- #include <linux/version.h>
-diff --git a/sysdeps/unix/sysv/linux/configure.ac b/sysdeps/unix/sysv/linux/configure.ac
-index 13abda0a51..6abc12eaed 100644
---- a/sysdeps/unix/sysv/linux/configure.ac
-+++ b/sysdeps/unix/sysv/linux/configure.ac
-@@ -50,7 +50,7 @@ fi
- AC_MSG_CHECKING(for kernel header at least $minimum_kernel)
- changequote(,)dnl
- decnum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/(\1 * 65536 + \2 * 256 + \3)/'`;
--abinum=`echo "$minimum_kernel.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
-+abinum=`echo "2.6.32.0.0.0" | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1,\2,\3/'`;
- changequote([,])dnl
- AC_TRY_COMPILE([#include <linux/version.h>
- #if LINUX_VERSION_CODE < $decnum
-diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
-index 823cd8224d..482caaeeec 100644
---- a/sysdeps/unix/sysv/linux/dl-osinfo.h
-+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
-@@ -39,7 +39,7 @@
- 	  GLRO(dl_osversion) = version;					      \
- 									      \
- 	/* Now we can test with the required version.  */		      \
--	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION)   \
-+	if (__LINUX_KERNEL_VERSION > 0 && version < __LINUX_KERNEL_VERSION && version != 0x020620)   \
- 	  /* Not sufficent.  */						      \
- 	  FATAL ("FATAL: kernel too old\n");				      \
-       }									      \
diff --git a/nixpkgs/pkgs/development/libraries/glibc/common.nix b/nixpkgs/pkgs/development/libraries/glibc/common.nix
index 6ed0a4d4da0f..00b78f57db61 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/common.nix
+++ b/nixpkgs/pkgs/development/libraries/glibc/common.nix
@@ -36,16 +36,16 @@
 , withLinuxHeaders ? false
 , profilingLibraries ? false
 , withGd ? false
-, meta
+, withLibcrypt ? false
 , extraBuildInputs ? []
 , extraNativeBuildInputs ? []
 , ...
 } @ args:
 
 let
-  version = "2.35";
-  patchSuffix = "-163";
-  sha256 = "sha256-USNzL2tnzNMZMF79OZlx1YWSEivMKmUYob0lEN0M9S4=";
+  version = "2.37";
+  patchSuffix = "-8";
+  sha256 = "sha256-Ilfv8RGhgV109GhW2q9AsBnB5VMVbGnUi6DL/Bu5GkM=";
 in
 
 assert withLinuxHeaders -> linuxHeaders != null;
@@ -53,23 +53,20 @@ assert withGd -> gd != null && libpng != null;
 
 stdenv.mkDerivation ({
   version = version + patchSuffix;
-  linuxHeaders = if withLinuxHeaders then linuxHeaders else null;
-
-  inherit (stdenv) is64bit;
 
   enableParallelBuilding = true;
 
   patches =
     [
       /* No tarballs for stable upstream branch, only https://sourceware.org/git/glibc.git and using git would complicate bootstrapping.
-          $ git fetch --all -p && git checkout origin/release/2.35/master && git describe
-          glibc-2.35-210-ge123f08ad5
-          $ git show --minimal --reverse glibc-2.35.. | gzip -9n --rsyncable - > 2.35-master.patch.gz
+          $ git fetch --all -p && git checkout origin/release/2.36/master && git describe
+          glibc-2.37-8-g590d0e089b
+          $ git show --minimal --reverse glibc-2.37.. | gzip -9n --rsyncable - > 2.37-master.patch.gz
 
          To compare the archive contents zdiff can be used.
-          $ zdiff -u 2.35-master.patch.gz ../nixpkgs/pkgs/development/libraries/glibc/2.35-master.patch.gz
+          $ zdiff -u 2.37-master.patch.gz ../nixpkgs/pkgs/development/libraries/glibc/2.37-master.patch.gz
        */
-      ./2.35-master.patch.gz
+      ./2.37-master.patch.gz
 
       /* Allow NixOS and Nix to handle the locale-archive. */
       ./nix-locale-archive.patch
@@ -85,42 +82,19 @@ stdenv.mkDerivation ({
          patch extends the search path by "/run/current-system/sw/bin". */
       ./fix_path_attribute_in_getconf.patch
 
-      /* Allow running with RHEL 6 -like kernels.  The patch adds an exception
-        for glibc to accept 2.6.32 and to tag the ELFs as 2.6.32-compatible
-        (otherwise the loader would refuse libc).
-        Note that glibc will fully work only on their heavily patched kernels
-        and we lose early mismatch detection on 2.6.32.
-
-        On major glibc updates we should check that the patched kernel supports
-        all the required features.  ATM it's verified up to glibc-2.26-131.
-        # HOWTO: check glibc sources for changes in kernel requirements
-        git log -p glibc-2.25.. sysdeps/unix/sysv/linux/x86_64/kernel-features.h sysdeps/unix/sysv/linux/kernel-features.h
-        # get kernel sources (update the URL)
-        mkdir tmp && cd tmp
-        curl http://vault.centos.org/6.9/os/Source/SPackages/kernel-2.6.32-696.el6.src.rpm | rpm2cpio - | cpio -idmv
-        tar xf linux-*.bz2
-        # check syscall presence, for example
-        less linux-*?/arch/x86/kernel/syscall_table_32.S
-       */
-      ./allow-kernel-2.6.32.patch
-
-      /* Provide a fallback for missing prlimit64 syscall on RHEL 6 -like
-         kernels.
-
-         This patch is maintained by @veprbl. If it gives you trouble, feel
-         free to ping me, I'd be happy to help.
-       */
-      (fetchurl {
-        url = "https://git.savannah.gnu.org/cgit/guix.git/plain/gnu/packages/patches/glibc-reinstate-prlimit64-fallback.patch?id=eab07e78b691ae7866267fc04d31c7c3ad6b0eeb";
-        sha256 = "091bk3kyrx1gc380gryrxjzgcmh1ajcj8s2rjhp2d2yzd5mpd5ps";
-      })
-
       ./fix-x64-abi.patch
 
       /* https://github.com/NixOS/nixpkgs/pull/137601 */
       ./nix-nss-open-files.patch
 
       ./0001-Revert-Remove-all-usage-of-BASH-or-BASH-in-installed.patch
+
+      /* Patch derived from archlinux (at the time of adding they're at 2.37),
+         https://github.com/archlinux/svntogit-packages/blob/packages/glibc/trunk/reenable_DT_HASH.patch
+
+        See https://github.com/NixOS/nixpkgs/pull/188492#issuecomment-1233802991 for context.
+      */
+      ./reenable_DT_HASH.patch
     ]
     ++ lib.optional stdenv.hostPlatform.isMusl ./fix-rpc-types-musl-conflicts.patch
     ++ lib.optional stdenv.buildPlatform.isDarwin ./darwin-cross-build.patch;
@@ -171,7 +145,7 @@ stdenv.mkDerivation ({
       # Enable Intel Control-flow Enforcement Technology (CET) support
       "--enable-cet"
     ] ++ lib.optionals withLinuxHeaders [
-      "--enable-kernel=3.2.0" # can't get below with glibc >= 2.26
+      "--enable-kernel=3.10.0" # RHEL 7 and derivatives, seems oldest still supported kernel
     ] ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
       (lib.flip lib.withFeature "fp"
          (stdenv.hostPlatform.gcc.float or (stdenv.hostPlatform.parsed.abi.float or "hard") == "soft"))
@@ -183,7 +157,9 @@ stdenv.mkDerivation ({
       # To avoid linking with -lgcc_s (dynamic link)
       # so the glibc does not depend on its compiler store path
       "libc_cv_as_needed=no"
-    ] ++ lib.optional withGd "--with-gd";
+    ]
+    ++ lib.optional withGd "--with-gd"
+    ++ lib.optional (!withLibcrypt) "--disable-crypt";
 
   makeFlags = [
     "OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
@@ -199,10 +175,14 @@ stdenv.mkDerivation ({
   nativeBuildInputs = [ bison python3Minimal ] ++ extraNativeBuildInputs;
   buildInputs = [ linuxHeaders ] ++ lib.optionals withGd [ gd libpng ] ++ extraBuildInputs;
 
-  # Needed to install share/zoneinfo/zone.tab.  Set to impure /bin/sh to
-  # prevent a retained dependency on the bootstrap tools in the stdenv-linux
-  # bootstrap.
-  BASH_SHELL = "/bin/sh";
+  env = {
+    linuxHeaders = lib.optionalString withLinuxHeaders linuxHeaders;
+    inherit (stdenv) is64bit;
+    # Needed to install share/zoneinfo/zone.tab.  Set to impure /bin/sh to
+    # prevent a retained dependency on the bootstrap tools in the stdenv-linux
+    # bootstrap.
+    BASH_SHELL = "/bin/sh";
+  };
 
   # Used by libgcc, elf-header, and others to determine ABI
   passthru = { inherit version; minorRelease = version; };
@@ -288,9 +268,5 @@ stdenv.mkDerivation ({
 
     maintainers = with maintainers; [ eelco ma27 ];
     platforms = platforms.linux;
-  } // meta;
-}
-
-// lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform) {
-  preInstall = null; # clobber the native hook
+  } // (args.meta or {});
 })
diff --git a/nixpkgs/pkgs/development/libraries/glibc/default.nix b/nixpkgs/pkgs/development/libraries/glibc/default.nix
index f941f7be769d..1c0c1b09e154 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/default.nix
+++ b/nixpkgs/pkgs/development/libraries/glibc/default.nix
@@ -2,6 +2,7 @@
 , withLinuxHeaders ? true
 , profilingLibraries ? false
 , withGd ? false
+, withLibcrypt? false
 , buildPackages
 }:
 
@@ -13,16 +14,17 @@ let
   ];
 in
 
-callPackage ./common.nix { inherit stdenv; } {
-    pname = "glibc" + lib.optionalString withGd "-gd";
-
-    inherit withLinuxHeaders profilingLibraries withGd;
+(callPackage ./common.nix { inherit stdenv; } {
+  inherit withLinuxHeaders withGd profilingLibraries withLibcrypt;
+  pname = "glibc" + lib.optionalString withGd "-gd";
+}).overrideAttrs(previousAttrs: {
 
     # Note:
     # Things you write here override, and do not add to,
     # the values in `common.nix`.
     # (For example, if you define `patches = [...]` here, it will
-    # override the patches in `common.nix`.)
+    # override the patches in `common.nix` -- so instead you should
+    # write `patches = (previousAttrs.patches or []) ++ [ ... ]`.
 
     NIX_NO_SELF_RPATH = true;
 
@@ -38,6 +40,9 @@ callPackage ./common.nix { inherit stdenv; } {
 
       # Apparently --bindir is not respected.
       makeFlagsArray+=("bindir=$bin/bin" "sbindir=$bin/sbin" "rootsbindir=$bin/sbin")
+    '' + lib.optionalString stdenv.buildPlatform.isDarwin ''
+      # ld-wrapper will otherwise attempt to inject CoreFoundation into ld-linux's RUNPATH
+      export NIX_COREFOUNDATION_RPATH=
     '';
 
     # The pie, stackprotector and fortify hardening flags are autodetected by
@@ -45,43 +50,53 @@ callPackage ./common.nix { inherit stdenv; } {
     # invocation does not work.
     hardeningDisable = [ "fortify" "pie" "stackprotector" ];
 
-    NIX_CFLAGS_COMPILE = lib.concatStringsSep " "
-      (builtins.concatLists [
-        (lib.optionals withGd gdCflags)
-        # Fix -Werror build failure when building glibc with musl with GCC >= 8, see:
-        # https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798
-        (lib.optional stdenv.hostPlatform.isMusl "-Wno-error=attribute-alias")
-        (lib.optionals ((stdenv.hostPlatform != stdenv.buildPlatform) || stdenv.hostPlatform.isMusl) [
-          # Ignore "error: '__EI___errno_location' specifies less restrictive attributes than its target '__errno_location'"
-          # New warning as of GCC 9
-          # Same for musl: https://github.com/NixOS/nixpkgs/issues/78805
-          "-Wno-error=missing-attributes"
-        ])
-      ]);
-
-    # When building glibc from bootstrap-tools, we need libgcc_s at RPATH for
-    # any program we run, because the gcc will have been placed at a new
-    # store path than that determined when built (as a source for the
-    # bootstrap-tools tarball)
-    # Building from a proper gcc staying in the path where it was installed,
-    # libgcc_s will now be at {gcc}/lib, and gcc's libgcc will be found without
-    # any special hack.
-    # TODO: remove this hack. Things that rely on this hack today:
-    # - dejagnu: during linux bootstrap tcl SIGSEGVs
-    # - clang-wrapper in cross-compilation
-    # Last attempt: https://github.com/NixOS/nixpkgs/pull/36948
-    preInstall = ''
-      if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then
-          mkdir -p $out/lib
-          cp ${stdenv.cc.cc}/lib/libgcc_s.so.1 $out/lib/libgcc_s.so.1
-          # the .so It used to be a symlink, but now it is a script
-          cp -a ${stdenv.cc.cc}/lib/libgcc_s.so $out/lib/libgcc_s.so
-      fi
-    '';
+    env = (previousAttrs.env or { }) // {
+      NIX_CFLAGS_COMPILE = (previousAttrs.env.NIX_CFLAGS_COMPILE or "") + lib.concatStringsSep " "
+        (builtins.concatLists [
+          (lib.optionals withGd gdCflags)
+          # Fix -Werror build failure when building glibc with musl with GCC >= 8, see:
+          # https://github.com/NixOS/nixpkgs/pull/68244#issuecomment-544307798
+          (lib.optional stdenv.hostPlatform.isMusl "-Wno-error=attribute-alias")
+          (lib.optionals ((stdenv.hostPlatform != stdenv.buildPlatform) || stdenv.hostPlatform.isMusl) [
+            # Ignore "error: '__EI___errno_location' specifies less restrictive attributes than its target '__errno_location'"
+            # New warning as of GCC 9
+            # Same for musl: https://github.com/NixOS/nixpkgs/issues/78805
+            "-Wno-error=missing-attributes"
+          ])
+          (lib.optionals (stdenv.hostPlatform.isPower64) [
+            # Do not complain about the Processor Specific ABI (i.e. the
+            # choice to use IEEE-standard `long double`).  We pass this
+            # flag in order to mute a `-Werror=psabi` passed by glibc;
+            # hopefully future glibc releases will not pass that flag.
+            "-Wno-error=psabi"
+          ])
+        ]);
+    };
+
+    # glibc needs to `dlopen()` `libgcc_s.so` but does not link
+    # against it.  Furthermore, glibc doesn't use the ordinary
+    # `dlopen()` call to do this; instead it uses one which ignores
+    # most paths:
+    #
+    #   https://sourceware.org/legacy-ml/libc-help/2013-11/msg00026.html
+    #
+    # In order to get it to not ignore `libgcc_s.so`, we have to add its path to
+    # `user-defined-trusted-dirs`:
+    #
+    #   https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/Makefile;h=b509b3eada1fb77bf81e2a0ca5740b94ad185764#l1355
+    #
+    # Conveniently, this will also inform Nix of the fact that glibc depends on
+    # gcc.libgcc, since the path will be embedded in the resulting binary.
+    #
+    makeFlags =
+      (previousAttrs.makeFlags or [])
+      ++ lib.optionals (stdenv.cc.cc?libgcc) [
+        "user-defined-trusted-dirs=${stdenv.cc.cc.libgcc}/lib"
+      ];
 
     postInstall = (if stdenv.hostPlatform == stdenv.buildPlatform then ''
       echo SUPPORTED-LOCALES=C.UTF-8/UTF-8 > ../glibc-2*/localedata/SUPPORTED
-      make -j''${NIX_BUILD_CORES:-1} -l''${NIX_BUILD_CORES:-1} localedata/install-locales
+      make -j''${NIX_BUILD_CORES:-1} localedata/install-locales
     '' else lib.optionalString stdenv.buildPlatform.isLinux ''
       # This is based on http://www.linuxfromscratch.org/lfs/view/development/chapter06/glibc.html
       # Instead of using their patch to build a build-native localedef,
@@ -131,15 +146,6 @@ callPackage ./common.nix { inherit stdenv; } {
       ln -sf $out/lib/libdl.so.2 $out/lib/libdl.so
       ln -sf $out/lib/libutil.so.1 $out/lib/libutil.so
       touch $out/lib/libpthread.a
-    ''
-      # For some reason these aren't stripped otherwise and retain reference
-      # to bootstrap-tools; on cross-arm this stripping would break objects.
-    + lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) ''
-
-      for i in "$out"/lib/*.a; do
-          [ "$i" = "$out/lib/libm.a" ] || $STRIP -S "$i"
-      done
-    '' + ''
 
       # Put libraries for static linking in a separate output.  Note
       # that libc_nonshared.a and libpthread_nonshared.a are required
@@ -158,5 +164,12 @@ callPackage ./common.nix { inherit stdenv; } {
 
     separateDebugInfo = true;
 
-    meta.description = "The GNU C Library";
-  }
+    passthru =
+      (previousAttrs.passthru or {})
+      // lib.optionalAttrs (stdenv.cc.cc?libgcc) {
+        inherit (stdenv.cc.cc) libgcc;
+      };
+
+  meta = (previousAttrs.meta or {}) // { description = "The GNU C Library"; };
+})
+
diff --git a/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh b/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh
index d732e208fa22..d91f936c937b 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh
+++ b/nixpkgs/pkgs/development/libraries/glibc/locales-builder.sh
@@ -1,3 +1,4 @@
+if [ -e .attrs.sh ]; then source .attrs.sh; fi
 # Glibc cannot have itself in its RPATH.
 export NIX_NO_SELF_RPATH=1
 
diff --git a/nixpkgs/pkgs/development/libraries/glibc/locales.nix b/nixpkgs/pkgs/development/libraries/glibc/locales.nix
index bada8b3f31f7..ed6f0a5b32ca 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/locales.nix
+++ b/nixpkgs/pkgs/development/libraries/glibc/locales.nix
@@ -19,19 +19,26 @@ callPackage ./common.nix { inherit stdenv; } {
 
   extraNativeBuildInputs = [ glibc ];
 
-  # Awful hack: `localedef' doesn't allow the path to `locale-archive'
-  # to be overriden, but you *can* specify a prefix, i.e. it will use
-  # <prefix>/<path-to-glibc>/lib/locale/locale-archive.  So we use
-  # $TMPDIR as a prefix, meaning that the locale-archive is placed in
-  # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive.
-  buildPhase =
-    ''
+  LOCALEDEF_FLAGS = [
+    (if stdenv.hostPlatform.isLittleEndian
+    then "--little-endian"
+    else "--big-endian")
+  ];
+
+  buildPhase = ''
+      # Awful hack: `localedef' doesn't allow the path to `locale-archive'
+      # to be overriden, but you *can* specify a prefix, i.e. it will use
+      # <prefix>/<path-to-glibc>/lib/locale/locale-archive.  So we use
+      # $TMPDIR as a prefix, meaning that the locale-archive is placed in
+      # $TMPDIR/nix/store/...-glibc-.../lib/locale/locale-archive.
+      LOCALEDEF_FLAGS+=" --prefix=$TMPDIR"
+
       mkdir -p $TMPDIR/"${buildPackages.glibc.out}/lib/locale"
 
       echo 'C.UTF-8/UTF-8 \' >> ../glibc-2*/localedata/SUPPORTED
 
       # Hack to allow building of the locales (needed since glibc-2.12)
-      sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef --prefix='$TMPDIR',' ../glibc-2*/localedata/Makefile
+      sed -i -e 's,^$(rtld-prefix) $(common-objpfx)locale/localedef,localedef $(LOCALEDEF_FLAGS),' ../glibc-2*/localedata/Makefile
     ''
       + lib.optionalString (!allLocales) ''
       # Check that all locales to be built are supported
@@ -57,8 +64,9 @@ callPackage ./common.nix { inherit stdenv; } {
 
   installPhase =
     ''
-      mkdir -p "$out/lib/locale"
+      mkdir -p "$out/lib/locale" "$out/share/i18n"
       cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale"
+      cp -v ../glibc-2*/localedata/SUPPORTED "$out/share/i18n/SUPPORTED"
     '';
 
   setupHook = writeText "locales-setup-hook.sh"
diff --git a/nixpkgs/pkgs/development/libraries/glibc/multi.nix b/nixpkgs/pkgs/development/libraries/glibc/multi.nix
index be190d77c736..5cd48958ec2c 100644
--- a/nixpkgs/pkgs/development/libraries/glibc/multi.nix
+++ b/nixpkgs/pkgs/development/libraries/glibc/multi.nix
@@ -1,4 +1,5 @@
-{ runCommand, glibc, glibc32
+{ lib
+, runCommand, glibc, glibc32
 }:
 
 let
@@ -7,7 +8,15 @@ let
 in
 runCommand "${nameVersion.name}-multi-${nameVersion.version}"
   # out as the first output is an exception exclusive to glibc
-  { outputs = [ "out" "bin" "dev" ]; } # TODO: no static version here (yet)
+  {
+    outputs = [ "out" "bin" "dev" ];  # TODO: no static version here (yet)
+    passthru = {
+      libgcc = lib.lists.filter (x: x!=null) [
+        (glibc64.libgcc or null)
+        (glibc32.libgcc or null)
+      ];
+    };
+  }
   ''
     mkdir -p "$out/lib"
     ln -s '${glibc64.out}'/lib/* "$out/lib"
diff --git a/nixpkgs/pkgs/development/libraries/glibc/reenable_DT_HASH.patch b/nixpkgs/pkgs/development/libraries/glibc/reenable_DT_HASH.patch
new file mode 100644
index 000000000000..f828b011bd9f
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/glibc/reenable_DT_HASH.patch
@@ -0,0 +1,145 @@
+From e47de5cb2d4dbecb58f569ed241e8e95c568f03c Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Fri, 29 Apr 2022 16:37:51 +0200
+Subject: [PATCH] Do not use --hash-style=both for building glibc shared
+ objects
+
+The comment indicates that --hash-style=both was used to maintain
+compatibility with static dlopen, but we had many internal ABI
+changes since then, so this compatiblity does not add value anymore.
+
+Reviewed-by: Carlos O'Donell <carlos@redhat.com>
+---
+ Makeconfig     |  9 +++++++++
+ Makerules      |  7 +++++++
+ config.make.in |  1 +
+ configure      | 28 ++++++++++++++++++++++++++++
+ configure.ac   | 16 ++++++++++++++++
+ 5 files changed, 61 insertions(+)
+
+diff --git b/Makeconfig a/Makeconfig
+index 760f14e92f..0aa5fb0099 100644
+--- b/Makeconfig
++++ a/Makeconfig
+@@ -362,6 +362,15 @@ relro-LDFLAGS = -Wl,-z,relro
+ LDFLAGS.so += $(relro-LDFLAGS)
+ LDFLAGS-rtld += $(relro-LDFLAGS)
+ 
++ifeq (yes,$(have-hash-style))
++# For the time being we unconditionally use 'both'.  At some time we
++# should declare statically linked code as 'out of luck' and compile
++# with --hash-style=gnu only.
++hashstyle-LDFLAGS = -Wl,--hash-style=both
++LDFLAGS.so += $(hashstyle-LDFLAGS)
++LDFLAGS-rtld += $(hashstyle-LDFLAGS)
++endif
++
+ ifeq (no,$(build-pie-default))
+ pie-default = $(no-pie-ccflag)
+ else # build-pie-default
+diff --git b/Makerules a/Makerules
+index 354528b8c7..428464f092 100644
+--- b/Makerules
++++ a/Makerules
+@@ -557,6 +557,13 @@ $(common-objpfx)shlib.lds: $(common-objpfx)config.make $(..)Makerules
+ 		  -Wl,--verbose 2>/dev/null | \
+ 	  sed > $@T \
+ 	      -e '/^=========/,/^=========/!d;/^=========/d' \
++	      $(if $(filter yes,$(have-hash-style)), \
++		   -e 's/^.*\.gnu\.hash[ 	]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
++		   -e '/^[ 	]*\.hash[ 	]*:.*$$/{h;d;}' \
++		   -e '/DATA_SEGMENT_ALIGN/{H;g}' \
++		, \
++		   -e 's/^.*\.hash[ 	]*:.*$$/  .note.ABI-tag : { *(.note.ABI-tag) } &/' \
++	       ) \
+ 	      -e 's/^.*\*(\.dynbss).*$$/& \
+ 		 PROVIDE(__start___libc_freeres_ptrs = .); \
+ 		 *(__libc_freeres_ptrs) \
+diff --git b/config.make.in a/config.make.in
+index fff4c78dd0..bf728c71c0 100644
+--- b/config.make.in
++++ a/config.make.in
+@@ -70,6 +70,7 @@ have-libcap = @have_libcap@
+ have-cc-with-libunwind = @libc_cv_cc_with_libunwind@
+ fno-unit-at-a-time = @fno_unit_at_a_time@
+ bind-now = @bindnow@
++have-hash-style = @libc_cv_hashstyle@
+ use-default-link = @use_default_link@
+ have-cxx-thread_local = @libc_cv_cxx_thread_local@
+ have-loop-to-function = @libc_cv_cc_loop_to_function@
+diff --git b/configure a/configure
+index 716dc041b6..5a730dc5fc 100755
+--- b/configure
++++ a/configure
+@@ -622,6 +622,7 @@ libc_cv_cc_nofma
+ libc_cv_mtls_dialect_gnu2
+ fno_unit_at_a_time
+ libc_cv_has_glob_dat
++libc_cv_hashstyle
+ libc_cv_fpie
+ libc_cv_z_execstack
+ ASFLAGS_config
+@@ -6193,6 +6194,33 @@ $as_echo "$libc_cv_fpie" >&6; }
+ 
+ 
+ 
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --hash-style option" >&5
++$as_echo_n "checking for --hash-style option... " >&6; }
++if ${libc_cv_hashstyle+:} false; then :
++  $as_echo_n "(cached) " >&6
++else
++  cat > conftest.c <<EOF
++int _start (void) { return 42; }
++EOF
++if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
++			    -fPIC -shared -o conftest.so conftest.c
++			    -Wl,--hash-style=both -nostdlib 1>&5'
++  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
++  (eval $ac_try) 2>&5
++  ac_status=$?
++  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
++  test $ac_status = 0; }; }
++then
++  libc_cv_hashstyle=yes
++else
++  libc_cv_hashstyle=no
++fi
++rm -f conftest*
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_hashstyle" >&5
++$as_echo "$libc_cv_hashstyle" >&6; }
++
++
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLOB_DAT reloc" >&5
+ $as_echo_n "checking for GLOB_DAT reloc... " >&6; }
+ if ${libc_cv_has_glob_dat+:} false; then :
+diff --git b/configure.ac a/configure.ac
+index d08ad4d64e..a045f6608e 100644
+--- b/configure.ac
++++ a/configure.ac
+@@ -1360,6 +1360,22 @@ LIBC_TRY_CC_OPTION([-fpie], [libc_cv_fpie=yes], [libc_cv_fpie=no])
+ 
+ AC_SUBST(libc_cv_fpie)
+ 
++AC_CACHE_CHECK(for --hash-style option,
++	       libc_cv_hashstyle, [dnl
++cat > conftest.c <<EOF
++int _start (void) { return 42; }
++EOF
++if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS $no_ssp
++			    -fPIC -shared -o conftest.so conftest.c
++			    -Wl,--hash-style=both -nostdlib 1>&AS_MESSAGE_LOG_FD])
++then
++  libc_cv_hashstyle=yes
++else
++  libc_cv_hashstyle=no
++fi
++rm -f conftest*])
++AC_SUBST(libc_cv_hashstyle)
++
+ AC_CACHE_CHECK(for GLOB_DAT reloc,
+ 	       libc_cv_has_glob_dat, [dnl
+ cat > conftest.c <<EOF
+-- 
+2.37.1
+