<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58926>58926</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            LLDB: feature suggestion: add rpath entries to executable search paths
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          russelltg
      </td>
    </tr>
</table>

<pre>
    When remote debugging with LLDB, it insists on loading the symbols from the target machine when they are available on the host machine in an easy-to-determine location.

Demo:

```bash
$ mkdir bin lib
$ echo "int get_number() { return 2; }" > lib.c
$ clang lib.c -shared -o lib/libshared.so
$ echo "int get_number();\nint main() { return get_number(); }" > main.c
$ clang main.c -o bin/main -L lib -l shared -Wl,-rpath,"\$ORIGIN/../lib"
$ rsync -r bin lib target:~/test
$ ssh -f target 'cd ~/test/bin && lldb-server platform --listen "*:1234" --server'
$ lldb 
> platform select remote-linux
> platform connect connect://target:1234
> file bin/main
> b main
> process launch
> image list
....
[  4] 207DCA7C-91F2-15DA-4470-4000F5EF9247-5C21C5A0 0x00007ffff7fbd000 /home/russell/.lldb/module_cache/remote-linux/.cache/207DCA7C-91F2-15DA-4470-4000F5EF9247-5C21C5A0/libshared.so
```

It had to sync that file across! This is obviously fine for this toy example, but for larger examples this is quite rough.
This can be worked around with a `settings append target.exec-search-paths lib` before the launch, but it seems like this should not be necessary as the RPATH is encoded right in the file and could automatically be added to the search path. 

Is there interest in this feature? I'm happy to work on it if so. I think the relevant code is towards the end of `TargetList::CreateTargetInternal`, but am not entirely sure. 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVU1v4zgM_TXOhbDhyPloDjmkSb0boNhdDArMcSDbjK2tLGUluW3-_ZKy02QwPewGRhKTFPn0RD5Vtrlsv3dowGFvA0KD1dC2yrTwrkIHz8-Hx0TsQQVQxisfPFgD2sqGQ0KH4C99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