Try harder to locate libMangoHud_opengl.so #1540
Draft
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.
shim: Show error messages from dlopen() where appropriate
If dlopen() returns null, then a subsequent dlerror() tells you why.
shim: Try to locate an adjacent libMangoHud_opengl.so using dladdr1()
When the Steam Linux Runtime's container tool pressure-vessel finds a
LD_PRELOAD module, it must map it into the filesystem namespace of the
container, and its procedure to achieve this in the presence of
$LIB
and other dynamic string tokens involves symbolic links in a temporary
directory.
However, this means we end up with a symlink to libMangoHud_shim.so in
$LD_PRELOAD
, and no corresponding symlink to libMangoHud_opengl.so inthe same directory, because pressure-vessel has no way to know that
we'll load the latter. In this situation, libdl expands
${ORIGIN}
to the directory containing the symlink, and not the directory below
/run/host that it points into.
We can improve on this by finding out the path to libMangoHud_shim.so
by looking up information about one of our own symbols, then using
realpath() to resolve that to a physical path somewhere below /run/host,
and resolving libMangoHud_opengl.so relative to that physical path.
The result is that we can find the implementation library.
steamrt/tasks#595