-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meson RPATH munging can yield libraries that break ldconfig on Linux #4685
Comments
If you want an example, the shared libraries in this conda package demonstrate the net effect:
|
Originally we did not remove the rpath entry but just left it empty. This is against distro packaging standards where rpath entries, even if empty, are forbidden. Any use of rpath must be documented and it can only be used for specific things (accessing internal libraries with an unstable ABI). Thus any change or fix done to this must preserve the removing behaviour. |
@jpakkane Relatedly ... it's surprising to me that this problem doesn't crop up more frequently. As I currently understand things, the changes that happen when RPATHs are removed can very easily lead to |
Rpath is not added if the ELF file in question does not link to any built shared libraries. As far as these things go, we have not had any bugs filed about broken rpaths like these and Meson is used by a fair chunk of the core infrastructure so one would imagine they would show up fairly quickly. |
We ran into another instance of conda-forge/glib-feedstock#40 AKA mesonbuild/meson#4685, in which Meson edits the rpaths of the binaries it installs in a way that breaks future `ldconfig` invocations. From previous investigations, setting an `install_rpath` for the installed binaries avoids the issue, so let's do that.
(This issue is inspired by conda-forge/glib-feedstock#40; see also NixOS/patchelf#44.)
I have found that in a corner case, Meson's ELF RPATH munging code can lead to installed shared libraries that are legal but confuse some tools that are not so smart about the ELF standard. Unfortunately one of those tools is
ldconfig
, and the breakage can lead it to create junk files that confuse other tools.The problem occurs when a shared library is installed on Linux and its
install_rpath
setting is the empty string (which appears to be the default). This triggers a codepath that removes the RPATH entry altogether. Unfortunately, as best I can take away from NixOS/patchelf#44, the way it does this rearranges the ELF file that confuses certain naive tools. For instance,chrpath
is one of these, and you can get a binary for whichreadelf -d
reports a good RPATH butchrpath -l
reports, essentially, garbage.Unfortunately, another one of these naive tools is
ldconfig
. It reads the SONAME string from ELF libraries to figure out what symlink name to create, and I ran into an example whereldconfig
decided to create a file named/usr/lib/\n
, containing a newline character. Unsurprisingly, the existence of such a file breaks all sorts of stuff.This is really
ldconfig
's fault, but the failure mode can be very hard to track down. Based on what I've seen, I think maybe Meson should look into alternative ways to implementremove_rpath_entry
that keepldconfig
happy. Reading that file, it seems as if there are other corner cases that have caused problems in the past, so a larger-bore solution might be worth considering too.The text was updated successfully, but these errors were encountered: