From 76f5618e1e591bb54b4e84cd769bb8fb10fed49f Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Wed, 4 Jan 2023 14:14:54 +0000 Subject: [PATCH] glibc: copy libgcc_s.so from .lib output if it exists Otherwise copy it from the default output. The difference is visible when we build `glibc` with: - `bootstrapTools` `gcc`: ${stdenv.cc.cc.out}/lib/libgcc_s.so.1 is used - `nixpkgs` `gcc`: ${stdenv.cc.cc.lib}/lib/libgcc_s.so.1 is used Noticed when experimented with multiple `gcc` rebuilds in bootstrap. While at it killing `RUNPATH` reference to bootstrap `glibc`. --- pkgs/development/libraries/glibc/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/glibc/default.nix b/pkgs/development/libraries/glibc/default.nix index 2d7e6614cecc9..dfe165c869d2f 100644 --- a/pkgs/development/libraries/glibc/default.nix +++ b/pkgs/development/libraries/glibc/default.nix @@ -76,11 +76,16 @@ in # - clang-wrapper in cross-compilation # Last attempt: https://github.com/NixOS/nixpkgs/pull/36948 preInstall = lib.optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' - if [ -f ${stdenv.cc.cc}/lib/libgcc_s.so.1 ]; then + if [ -f ${lib.getLib 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 + cp ${lib.getLib 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 + cp -a ${lib.getLib stdenv.cc.cc}/lib/libgcc_s.so $out/lib/libgcc_s.so + # wipe out reference to previous libc it was built against + chmod +w $out/lib/libgcc_s.so.1 + # rely on default RUNPATHs of the binary and other libraries + # Do no force-pull wrong glibc. + patchelf --remove-rpath $out/lib/libgcc_s.so.1 fi '';