From b5d70d2ffbf2b9e7ed52ba256d5e633d1404b0d2 Mon Sep 17 00:00:00 2001 From: countgitmick <263313427+countgitmick@users.noreply.github.com> Date: Wed, 8 Apr 2026 15:00:32 -0700 Subject: [PATCH] make-initrd-ng: suppress spurious glibc dependency warnings In Nix, glibc libraries lack rpath entries pointing to themselves, so libc.so.6 and ld-linux-*.so.* can never be resolved through rpath alone during initrd generation. They are always present in the initrd through other paths (the ELF interpreter and other binaries' rpath entries). The scripted initrd builder (stage-1.nix findLibs) already skips ld*.so.? for the same reason. This brings make-initrd-ng in line with that precedent. Also removes two unused imports (PermissionsExt, Command) and moves the remaining warning output from stdout to stderr. Closes #463894 Closes #282145 Closes #399281 --- .../kernel/make-initrd-ng/src/main.rs | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs index 85449c7eb027..b04e546d388a 100644 --- a/pkgs/build-support/kernel/make-initrd-ng/src/main.rs +++ b/pkgs/build-support/kernel/make-initrd-ng/src/main.rs @@ -5,9 +5,7 @@ use std::fs; use std::hash::Hash; use std::iter::FromIterator; use std::os::unix; -use std::os::unix::fs::PermissionsExt; use std::path::{Component, Path, PathBuf}; -use std::process::Command; use libc::umask; @@ -159,13 +157,22 @@ fn add_dependencies + AsRef + std::fmt::Debug>( } } if !found { - // glibc makes it tricky to make this an error because - // none of the files have a useful rpath. - println!( - "Warning: Couldn't satisfy dependency {} for {:?}", - line, - OsStr::new(&source) - ); + // In Nix, glibc's own libraries lack rpath entries pointing to + // themselves, so the dynamic linker (ld-linux-*.so.*) and libc.so.* + // can never be resolved through rpath alone. They are always present + // in the initrd: the linker via elf.interpreter above, and libc via + // at least one binary's rpath. Suppress these known-benign cases. + // See also: the ld*.so.? skip in stage-1.nix findLibs. + let is_glibc_runtime = (line.starts_with("ld-") && line.contains(".so")) + || line.starts_with("libc.so"); + + if !is_glibc_runtime { + eprintln!( + "Warning: Couldn't satisfy dependency {} for {:?}", + line, + OsStr::new(&source) + ); + } } }