From b0d26fa2cdd3c8a5d298f94e3e0d19218b85c0c7 Mon Sep 17 00:00:00 2001 From: Guillaume Girol Date: Thu, 29 May 2025 12:00:00 +0000 Subject: [PATCH] autoPatchelfHook: teach it to avoid objects created by separateDebugInfo otherwise systemd fails to build because autoPatchelfHook patches libs with debug objects and this creates circular dependencies from out to debug (of course, debug depends on out) example of faulty behavior: searching for dependencies of /nix/store/c8cd7b82py02f0rkags351nhg82wwjm6-systemd-minimal-257.5/bin/systemd-delta libsystemd-shared-257.so -> found: /nix/store/icpqrawjhsw4fbi4i2hp7cxvf3kbzq7m-systemd-minimal-257.5-debug/lib/debug libc.so.6 -> found: /nix/store/7lyblga0bzjk0sl93vp4aiwbvb57vp2x-glibc-2.40-66/lib --- pkgs/build-support/setup-hooks/auto-patchelf.sh | 1 + pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh index 541b7fc694d0..9f195ceead82 100644 --- a/pkgs/build-support/setup-hooks/auto-patchelf.sh +++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh @@ -95,6 +95,7 @@ autoPatchelfPostFixup() { if [[ -z "${dontAutoPatchelf-}" ]]; then autoPatchelf -- $(for output in $(getAllOutputNames); do [ -e "${!output}" ] || continue + [ "${output}" = debug ] && continue echo "${!output}" done) fi diff --git a/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py b/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py index 3426752fa55a..bf8882818dd9 100644 --- a/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py +++ b/pkgs/by-name/au/auto-patchelf/source/auto-patchelf.py @@ -42,6 +42,13 @@ def is_dynamic_executable(elf: ELFFile) -> bool: # section but their ELF type is DYN. return bool(elf.get_section_by_name(".interp")) +def is_separate_debug_object(elf: ELFFile) -> bool: + # objects created by separateDebugInfo = true have all the section headers + # of the unstripped objects but those that normal `strip` would have kept + # are NOBITS + text_section = elf.get_section_by_name(".text") + return elf.has_dwarf_info() and bool(text_section) and text_section.header['sh_type'] == "SHT_NOBITS" + def get_dependencies(elf: ELFFile) -> list[list[Path]]: dependencies = [] @@ -174,6 +181,10 @@ def populate_cache(initial: list[Path], recursive: bool =False) -> None: try: with open_elf(path) as elf: + if is_separate_debug_object(elf): + print(f"skipping {path} because it looks like a separate debug object") + continue + osabi = get_osabi(elf) arch = get_arch(elf) rpath = [Path(p) for p in get_rpath(elf)