From 51483cb254596aee9d2056ea1cab6ceb9c08e148 Mon Sep 17 00:00:00 2001 From: Petar Kirov Date: Fri, 21 Apr 2023 10:18:02 +0300 Subject: [PATCH] fix(dmd/binary): Ensure `autoPatchelfHook` is able to find `libgcc_s.so.1` After upgrading to a recent version of Nixpkgs (2023-04-18), the build broke with the following error: ... auto-patchelf: 6 dependencies could not be satisfied error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/lib/libphobos2.so.0.98.0 error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/rdmd error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dub error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dustmite error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/ddemangle error: auto-patchelf could not satisfy dependency libgcc_s.so.1 wanted by /nix/store/kl8bjrlmlzcjz47c0n6kjsj1yxi6zpqm-dmd-binary-2.098.0/bin/dmd auto-patchelf failed to find all the required dependencies. ... After investigation, it turned out that the cuase was a recent [change in Nixpkgs][0] after which `libgcc_s.so` is no longer part of the `glibc` package: Before (nixpkgs @ 2022-03-30): > nix build --json 'github:NixOS/nixpkgs/710fed5a2483f945b14f4a58af2cd3676b42d8c8#glibc^out' \ | jq -r '.[0].outputs.out' \ | xargs -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*' /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so.1 /nix/store/q29bwjibv9gi9n86203s38n0577w09sx-glibc-2.33-117/lib/libgcc_s.so After (nixpkgs @ 2023-04-18): > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#glibc^out' \ | jq -r '.[0].outputs.out' \ | xargs -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*' (no output) Instead, we should use `gccForLibs.libgcc` as it includes exactly what we need: > nix build --json 'github:NixOS/nixpkgs/555daa9d339b3df75e58ee558a4fec98ea92521e#gccForLibs^libgcc' \ | jq -r '.[0].outputs.libgcc' \ | xargs -I{} find {} \( -type l -or -type f \) -name '*libgcc_s*' /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so.1 /nix/store/5w5qpm9z3iyib615pdih6nvk9spv3jbv-gcc-12.2.0-libgcc/lib/libgcc_s.so This is nixpkgs again @ 2023-04-18, this time using `gccForLibs.libgcc` instead of `glibc.out`. [`gccForLibs`][1] is essentially `gcc.lib`: * an alias to `stdenv.cc.cc` if the host and target are the same and are GNU or * an alias to `gcc.cc` when `stdenv` is LLVM based as then `stdenv.cc.cc` would refer to clang and the `lib` output point to libclang libs, which are very different from what we need. [0]: https://github.com/NixOS/nixpkgs/pull/209870 [1]: https://github.com/NixOS/nixpkgs/pull/91293 --- pkgs/dmd/binary.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/dmd/binary.nix b/pkgs/dmd/binary.nix index 21e679be..4a2ce4cf 100644 --- a/pkgs/dmd/binary.nix +++ b/pkgs/dmd/binary.nix @@ -6,7 +6,7 @@ tzdata, autoPatchelfHook, fixDarwinDylibNames, - glibc, + gccForLibs, version, hashes, }: let @@ -37,7 +37,7 @@ in lib.optional hostPlatform.isLinux autoPatchelfHook ++ lib.optional hostPlatform.isDarwin fixDarwinDylibNames; - propagatedBuildInputs = [curl tzdata] ++ lib.optional hostPlatform.isLinux glibc; + propagatedBuildInputs = [curl tzdata] ++ lib.optional hostPlatform.isLinux gccForLibs.libgcc; installPhase = '' runHook preInstall