It seems impossible to me, but around the time I installed the latest command line tools (xcode-select version 2397) binaries what were built with linkages to @rpath/libfoo.dyld stopped being able to find their dependency. The error looks like this.
dyld[1471]: Symbol not found: _GEOSGeomGetX
Referenced from: <16DBE67F-CB32-31EE-BCE0-BFB58EEC9740> /Users/pramsey/tmp/capi_indexed_predicate
Expected in: <no uuid> unknown
zsh: abort ./capi_indexed_predicate
If I turn on DYLD_PRINT_SEARCHING, I can see the linker giving up on the rpath entry.
dyld[1501]: find path "@rpath/libgeos_c.1.dylib"
dyld[1501]: not found: "@rpath/libgeos_c.1.dylib"
I can work around, partially, by setting DYLD_LIBRARY_FALLBACK_PATH to have /usr/local/lib in it, but that is only a partial fix, because SIP will strip that variable for any child processes, which means most of my development and database work is borked.
This seems like a very new quirk, maybe related to the XCode 15 update, at least in my personal time line, has anyone else seen it, or have any clue as to what has changed? (Worth noting, nothing changed in my code, just one day my builds wouldn't run anymore, and that day was the day after I had installed the new commandline tools).
I should add, that the issue is very easy to reproduce (at least on my system). Install a library in /usr/local/lib. Write a test program that links that library. Build it (no errors). Run it, and it fails, with that "Expected in: <no uuid> unknown". In my case I used an example program from the GEOS library,
cc -I/usr/local/include capi_indexed_predicate.c -o capi_indexed_predicate -L/usr/local/lib -lgeos_c
There are others seeing this, but so far it seems a small group. https://stackoverflow.com/questions/77137284/dynamic-linker-fails-to-find-symbol-at-runtime-after-updating-to-xcode-15
YOLO, so I just updated to 13.6 and nothing has changed, still cannot resolve libraries in /usr/local/lib.