-
Notifications
You must be signed in to change notification settings - Fork 12.2k
cmake : set RPATH
to $ORIGIN
on Linux (#13740)
#13741
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
This is crucial for enabling the official distribution to be used as a true portable dynamically linked library. Currently the embedded RPATH points to an absolute path that almost no one would have (
So basically without setting a global Why it's a significant problemIt's a significant issue for a wrapper library I'm publishing, since at the current state, users can't use the official distribution Adding similar arguments for macOS buildsSame can be done for macOS builds. When I compile I add:
|
You can run |
Default To fix that, if I build myself, I use My own cmake command looks like this:
Of course I can rebuild myself, but I can't do that in the rapid pace that the library gets updated at, or have access to all platforms.. It's much more productive to use the official dynamic libraries from the official distribution. The EditI gave the |
The linux releases are very bare bones, I cannot recommend using them for anything other than testing. However, it would be ok to modify the way the linux releases are built in |
It doesn't personally matter to me if the default build parameters set RPATH to search in the local directory, since if I do build myself, I use custom build parameters anyway (which took a lot of time and LLM assistance to refine, though). Having the official released binaries have RPATH settings that are more usable towards portable distributions would be great, since they are already effectively distributed in a "portable" way, implying you could just copy and use them. Also, in the releases, the executables themselves, like
If you run it, it still works, because likely that on Linux there is a fallback to search dependencies at the current working directory. However, in slightly more complex applications, like mine, I cannot guarantee what the CWD would be, and it's not a good idea to modify it, even temporarily (unsafe, especially threading involved!). The simple and direct way to resolve this is likely ensure that the binary files are designed to directly "find each other" in the same directory they are located. It assumes a portable distribution which is pretty much how the releases are organized. Also, the change should probably also be done for the macOS I could try to give a pull request but I noticed there are many different files involved in the CI, with some custom shell scripts, so I don't really know where should I make the changes. It's a bit overwhelming. |
The linux releases are created entirely here, the other files are not relevant. llama.cpp/.github/workflows/release.yml Lines 128 to 235 in 06cbedf
|
Update: this may actually be seen as a bugIf you try to run
The suggested change is expected to fix this (edit: need to verify to be 100% sure). |
I tested changing to I created pull request #14309 with the changes (macOS builds already had related CMAKE arguments, it turns out). |
Since many people need to build for themselves on Linux, I'm afraid that simply changing |
The way I see it, there are essentially two reason to build llama.cpp on Linux:
|
Here's how I see it: The build process puts all the binaries in a single flat directory, which makes things easy for distribution and deployment. So, if the user is interested in copying those to another location, it kind of seems like everything should work just fine, but in practice, without special compiler parameters (which are kind of obscure and not known to most users), it wouldn't really work as expected due to the absolute search paths the binaries embed (unless binaries are in global path or in current working directory). The absolute search paths, at this stage, are not "installation" paths. They are local paths to the build directory used for compilation. They don't actually provide a real "service" to the user. Actually they could be a source of confusion and error, since if the binary is copied to another location, and the binary embeds an absolute search path to a build directory (which is highest priority in search), later the build directory may contain different, incompatible builds, so the copied binary might work initially, but then mysteriously fail because the shared library files in the build directory has been recompiled to a different, incompatible version. |
Setting
However, this approach generates binaries that cannot be moved to another path. Setting There is also a specific scenario where setting Since in all three of these situations, setting |
This patch makes the commands callable from any working directory.