-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Bugfix: Generated binaries should not depend on devel package paths #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
|
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 |
|
Rebased on top of master. |
|
Rebased on top of master so the CI checks pass. |
|
Rebased on top of master. |
| # Resolve the path as a compiler in the build directory would | ||
| path = os.path.join(self.env.get_build_dir(), path) | ||
| prefix_libpaths.add(path) | ||
| prefix_libpaths.add(Path(path).resolve().as_posix()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why .as_posix()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On windows, Meson chooses to keep prefix_libpaths as posix. I don't know why. Sorry, I don't know much about windows. The honest answer is that the windows tests in the CI failed without this, and looking at the difference from what was expected, this fix was obvious.
If it's worth anything, I see .as_posix() used in line 276 of the same file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also the following comment on line 219: # pkg-config paths follow Unix conventions, even on Windows
|
Rebased. |
|
Rebased. |
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
|
Rebased. |
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 addreturns 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:
libaddandlibadd-devel.The first installs the following files (under
/optor/usr/localas the system administrator chooses):The second, which is the development package, installs the following files:
The file
add.pcis 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
libaddon those machines, notlibadd-devel, normeson,ninja, etc.The problem is that, without this patch, a
meson.buildfile 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/pkgconfigdoes not exist there.With this patch:
and all is well.