Dynamic library loader: search in -L
directories before default ones
#13069
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #12214.
The link flags for OpenSSL and libcrypto already include the explicit directory returned by
pkg-config
, because at one point we wanted to detect OpenSSL 1.0.2 and enable its new features if found. The problem is that our loader always tries the default library paths before ones specified via the-L
s from the link flags, and the first entry is/usr/lib
, which means the system libraries are always searched first, and/usr/lib/libcrypto.dylib
is specifically made to abort any application that attempts to load it.That failure also happens with a plain
dlopen
, by the way:The MSVC loader already searches in the directories specified via
/LIBPATH
before the default ones.