-
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
Add an option to have @rpath install_name instead of an absolute path #2121
Comments
Getting this fixed is of critical importance for the ability to even consider using |
This also impacts gobject-introspection files, which end up with the build path hard coded since they're taking their cues from the LC_ID_DYLIB. So even if you fix up the dylibs manually after installation, you still have broken gobject-introspection files. |
I'm running into this as well - did a precise write-up and opened a separate issue so as not to hijack this thread: #3077 |
Using an absolute |
I cannot find the exact location, but someone asked me how this issues is handled in CMake. Please take a look at a hello-world example that I have put on https://github.com/mojca/test-meson-libraries. In short: CMake would call |
Based on the sample code, everyone would need to set an install_name property on all their targets. We can certainly add that but it is a bit imperfect. Is there a way to make this work correct automatically (say, 95% of the time)? |
As an example we could have a new option, say, |
@jpakkane both CMake and libtool get it right? Set a temporary install_name and/or RPATH during build, and relink with correct absolute install_name during install? |
Not relinking, direct manipulation by |
@jpakkane this is somewhat related too: I've noticed that Meson doesn't remove RPATHs when installing, leaving the RPATHs in the binaries |
Isn't that what you get anyway if you don't use the install_name option but just let the toolchain figure things out? |
Well, no. CMake uses |
And the MacPorts CMake PortGroup sets |
No. If you don't set a library's
I don't know cmake well so I can't tell you what that does. But ports in MacPorts that build with cmake end up with their libraries' |
It makes package relocation easier when a library's If |
On Sunday March 26 2023 01:37:54 Albert Jin wrote:
> Ports that build with ***@***.***` in their `install_name`s cause various issues, so we seek them out and fix them so that they do not contain ***@***.***` anymore.
[...]
If `meson` does not support this feature, it just means that there is a limitation in the build tool. It can be simply fixed by `install_name_tool` with extra effort. It smells bad of `meson`.
Just to be clear: the "Ports that build with..." quote came from a MacPorts developer. MacPorts uses the principle that all libraries are expected to be in their designated locations so that the presence of another version or variant of that same library in a different location cannot lead to problems. That's another use case and I think we agree on the fact that build tools should enable freedom of choice in this matter rather than preach what it considers official gospel.
|
Would someone like to submit a proposal in PR form, that adds a configure time option for this? It seems like a reasonable thing to accept... |
Description
Meson's
RPATH
andinstall_name
handling are currently broken on macOS. Here's a toy example. Letfoo
be the library (aka the provider) and letbar
be the executable (aka the consumer). For foo we have:foo.cpp:
foo.hpp:
meson.build:
For bar we have:
bar.cpp:
meson.build:
How to reproduce
in foo (the
rm -r build
at the end is crucial to reproduce the issue):in bar:
which then greets you with a message:
The actual problem
The culprit is how meson builds libraries on macOS. The linking line is currently:
which is incorrect. MacOS has a peculiar and very unusual way of linking, namely that consumers of a library inherit a provider's
install_name
. If you runotool -l
on the library you getwhere the name is clearly wrong, as it uses the builddir name. As an absolute minimum this should have been
/Users/Soap/Desktop/PREFIX/lib/libfoo.dylib
(but hold on, you still don't want this). This is why, when not runningrm -r build
in foo, the linking seems to work, because bar is still using the build dir lib, not the installed one.Furthermore, another peculiarity of macOS is the fact that for
RPATH
of consumers to work, the provider has to play along. This is different from Linux, whereRPATH
/RUNPATH
are purely a consumer problem, the provider does not have to know about consumers'RPATH
behaviour. Thus, in order forRPATH
to work for consumers, theinstall_name
has to be@rpath/<libname>.dylib
. In a quick and hacky way, doing this infoo
:And then in bar (notice the missing colon
:
after-Wl,-rpath,
):and then
./bar
gives meConclusion
This issue is caused by macOS' unconventional linking behaviour, and the fact that library providers have to be
RPATH
aware, which is unduly burdensome and complicates things. I believe the following to be the best line of operation:-install_name @rpath/<libname>.dylib
unconditionally, purely to be consumed in anRPATH
-capable way. While using an absoluteinstall_name
would make things a bit easier in the short run, this is short-sighted and a path full of pain. There are two reasons to avoid absoluteinstall_name
s:RPATH
-based builds are relocatable.RPATH
s in a relative way, where@loader_path
is the proper analogue to$ORIGIN
on Linux.References
conda/conda-build#279
https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
https://wincent.com/wiki/%40executable_path%2C_%40load_path_and_%40rpath
http://jorgen.tjer.no/post/2014/05/20/dt-rpath-ld-and-at-rpath-dyld/
The text was updated successfully, but these errors were encountered: