From f5353dd50e51524cb3367010647e70662991343f Mon Sep 17 00:00:00 2001 From: David McFarland Date: Sun, 8 Feb 2026 18:51:59 -0400 Subject: [PATCH] cygwin-dll-link: improve search path order The search order will now be: 1. link target path 2. output bin paths 3. explicit input paths (e.g. libc) 4. HOST_PATH --- pkgs/build-support/cc-wrapper/default.nix | 2 +- .../cygwin-dll-link-hook/cygwin-dll-link.sh | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 89cc7c4ce4fd..808fe5db2780 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -603,7 +603,7 @@ stdenvNoCC.mkDerivation { installPhase = if targetPlatform.isCygwin then '' - echo addToSearchPath "HOST_PATH" "${cc_solib}/bin" >> $out + echo addToSearchPath "_linkDeps_inputPath" "${cc_solib}/bin" >> $out # Work around build failure caused by the gnulib workaround for # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114870. remove after # gnulib is updated in core packages (e.g. iconv, gnupatch, gnugrep) diff --git a/pkgs/os-specific/cygwin/cygwin-dll-link-hook/cygwin-dll-link.sh b/pkgs/os-specific/cygwin/cygwin-dll-link-hook/cygwin-dll-link.sh index 6fe69347861e..3711ef494ed1 100644 --- a/pkgs/os-specific/cygwin/cygwin-dll-link-hook/cygwin-dll-link.sh +++ b/pkgs/os-specific/cygwin/cygwin-dll-link-hook/cygwin-dll-link.sh @@ -8,13 +8,15 @@ _moveDLLsToLib() { preFixupHooks+=(_moveDLLsToLib) -addOutputDLLPaths() { +declare _linkDeps_inputPath _linkDeps_outputPath + +_addOutputDLLPaths() { for output in $(getAllOutputNames); do - addToSearchPath "HOST_PATH" "${!output}/bin" + addToSearchPath _linkDeps_outputPath "${!output}/bin" done } -preFixupHooks+=(addOutputDLLPaths) +preFixupHooks+=(_addOutputDLLPaths) _dllDeps() { @objdump@ -p "$1" \ @@ -35,12 +37,13 @@ _linkDeps() { continue fi # Locate the DLL - it should be an *executable* file on $HOST_PATH. - local dllPath - if ! dllPath="$(PATH="$(dirname "$target"):$HOST_PATH" type -P "$dll")"; then + local dllPath searchPath + searchPath=$(dirname "$target"):$_linkDeps_outputPath:$_linkDeps_inputPath:$HOST_PATH + if ! dllPath="$(PATH="$searchPath" type -P "$dll")"; then if [[ -z "$check" || -n "${allowedImpureDLLsMap[$dll]}" ]]; then continue fi - echo unable to find "$dll" in "$HOST_PATH" >&2 + echo unable to find "$dll" in "$searchPath" >&2 exit 1 fi echo ' linking to:' "$dllPath"