-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
dependencies/pkgconfig: Canonicalize libpaths #14426
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
base: master
Are you sure you want to change the base?
Conversation
Prefix library paths specified by -L are converted to canonical paths to improve the library runpath stored in the binary output. For example, if `pkg-config --libs add` returns the following: -L/usr/local/lib/pkgconfig/../../lib -ladd we convert the path so that it is as if it had returned: -L/usr/local/lib -ladd
The motivation here sounds quite wrong. If you're distributing libadd to hundreds of machines and the administrator of each machine can choose where to install it, because it's a relocatable package and uses The only correct option is to evaluate the pcfiledir pkg-config variable in the text used for rpath, with the rpath token |
In this scenario, there's only one administrator, who creates two disk images (one for the build machine and one for the deployment machines). The only difference between the two images is whether or not Sorry, I'm not really understanding your suggestion. The As the developer of The dependency code for pkgconfig already converts relative paths to absolute paths. |
With this PR:
The executable |
No, if the pkg-config path is relocatable, then the library is intended to be moved around. Turning that into an absolute path would break lots of usages. Instead, your app should make sure that it lives where the library expects you to be (by looking at $ORIGIN). If you can't do that, then you need to use LD_LIBRARY_PATH. |
The meson code in
According to the comments, it does this because, "We need the full path of the library to calculate RPATH values" and because, "De-dup of libraries is easier when we have absolute paths." If the library moves around, it seems to me that my patch doesn't make the problem any worse. Do you see a use case for which the absolute path with the Certainly, if the library is moved around from one machine to the next, then whoever is running the application would need to use I do not see how
The third-party math library has no idea that It seems common for third-party libraries to ship their product in two pieces, e.g., I would like to run
on the build machine to have I think the same thing happens with Kubernetes deployments--a minimized container image without |
Prefix library paths specified by -L are converted to canonical paths to improve the library runpath stored in the binary output. For example, if
pkg-config --libs add
returns the following:we convert the path so that it is as if it had returned:
Motivation
Consider a third-party math library that is distributed as two packages for installation:
libadd
andlibadd-devel
.The first installs the following files (under
/opt
or/usr/local
as the system administrator chooses):The second, which is the development package, installs the following files:
The file
add.pc
is as follows:On a build machine, the sysadmin has installed both packages. But the application that uses this math library will be deployed on hundreds of machines (virtual machines in the cloud, nodes on a supercomputer, docker containers, etc.). The system administrator only installs
libadd
on those machines, notlibadd-devel
, normeson
,ninja
, etc.The problem is that, without this patch, a
meson.build
file containingwill create an application binary with the following library runpath:
and this won't run on the deployment nodes since the directory
/usr/local/lib/pkgconfig
does not exist there.With this patch:
and all is well.