[lld/mac] Print dylib search details with --print-dylib-search or…

Authored by thakis on Jun 9 2021, 12:16 PM.


[lld/mac] Print dylib search details with --print-dylib-search or RC_TRACE_DYLIB_SEARCHING

For debugging dylib loading, it's useful to have some insight into what
the linker is doing.

ld64 has the undocumented RC_TRACE_DYLIB_SEARCHING env var
for this printing dylib search candidates.

This adds a flag --print-dylib-search to make lld print the seame information.
It's useful for users, but also for writing tests. The output is formatted
slightly differently than ld64, but we still support RC_TRACE_DYLIB_SEARCHING
to offer at least a compatible way to trigger this.

ld64 has both -print_statistics and -trace_symbol_output to enable
diagnostics output. I went with "print" since that seems like a more
straightforward name.

Differential Revision: https://reviews.llvm.org/D103985