Commit f5353dd5 authored by David McFarland's avatar David McFarland
Browse files

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
parent f2ac4eef
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)
+9 −6
Original line number Diff line number Diff line
@@ -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"