From 7bc32b3e5cc623a7b4b0fad900db26258592b9e6 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sun, 22 Aug 2021 19:40:56 +0200 Subject: [PATCH] glibc: symlink `libpthread.so -> libpthread.so.0` (same for `-lrt`) for backwards compatibility Linking via `-lpthread` (or `-pthread`) is not needed anymore since `glibc-2.34` since all the functionality is part of `libc.so.6` and `libpthread.so.6` only exists for backwards-compatibility. However, e.g. `gcc` (`libgomp` to be precise) expects a `libpthread.so` to link against, otherwise the configure script will fail. As already stated in the glibc release-notes itself, it is to expect that a lot more applications will have issues with this, so I decided to re-add `libpthread.so` as well. For `librt.so.1`, the same thing is needed to make sure that Perl still compiles: /nix/store/d6y5r7m93x14bmgn2p75fannz39jz66f-binutils-2.35.1/bin/ld: cannot find -lrt collect2: error: ld returned 1 exit status make[1]: *** [Makefile:490: ../../lib/auto/Time/HiRes/HiRes.so] Error 1 make[1]: Leaving directory '/build/perl-5.34.0/dist/Time-HiRes' --- pkgs/development/libraries/glibc/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index caaacfe4f436..dfe1d2db7d58 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -119,6 +119,14 @@ callPackage ./common.nix { inherit stdenv; } { # Get rid of more unnecessary stuff. rm -rf $out/var $bin/bin/sln + + # Backwards-compatibility to fix e.g. + # "configure: error: Pthreads are required to build libgomp" during `gcc`-build + # because it's not actually needed anymore to link against `pthreads` since + # it's now part of `libc.so.6` itself, but the gcc build breaks if + # this doesn't work. + ln -sf $out/lib/libpthread.so.0 $out/lib/libpthread.so + ln -sf $out/lib/librt.so.1 $out/lib/librt.so '' # For some reason these aren't stripped otherwise and retain reference # to bootstrap-tools; on cross-arm this stripping would break objects.