-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
[wip] meson: append new items to the original rpath #31228
Conversation
Some apps require an internal library, that needs to be added to rpath. In 8f95aef, we removed the rpath fixup, breaking these apps. This commit re-adds the fixup but modifies it to keep the old rpath. Closes: NixOS#31222
2ab287b
to
7214d0f
Compare
Also see: mesonbuild/meson#314. This will break it: https://github.com/mesonbuild/meson/blob/db34a3a7017d0096faa8d3f020efd078ad8a65e1/mesonbuild/scripts/depfixer.py#L303-L306 Can't be easily patched in Meson because they just overwrite bytes in ELF headers without much handling logic. Perhaps better approach would be to replace |
Hmm, you are right, it will be broken with non empty Edit: Apparently, meson does the exact same thing |
There is probably no upstreamable fix other than implementing a flag like Or perhaps they will upstream resizing logic (to handle the case when By the way, see: pkgs/development/tools/build-managers/cmake/setup-hook.sh#L52 This should have the same effect as skipping rpath fixup entirely (which is what we currently do with Meson). How come CMake builds that have internal libraries aren't affected? |
I tried using the patchelf approach in #31219 but now deja-dup segfaults. |
Some apps require an internal library, that needs to be added to rpath. In 8f95aef, we removed the rpath fixup, breaking these apps. This commit re-adds the fixup but modifies it to keep the old rpath. Closes: NixOS#31222
Apparently, the patchelf tool can corrupt the binary, same thing happens with GNOME Shell in #29392 (comment) |
- sys.exit('File "%s" has unknown ELF endianness.' % self.bfile) | ||
- return ptrsize, is_le | ||
- | ||
- def parse_header(self): |
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.
When it goes into the tree, I'd suggest making the patch as small as possible so that it's not a maintenance burden. You probably already have that in mind, but just in case...
Since Python functions can be redefined, the most forward-compatible way of doing this is storing patchelf versions of self.print_soname()
and self.fix_rpath()
in a .py
file that then will be appended to scripts/depfixer.py
in patchPhase
.
Unfortunately, sometimes it does (and it can't patch some binaries at all). Have you tried |
Why does not the compiler/linker produce the correct rpath in the first place? It looks like it tries – the libraries are |
Because shared libraries are moved to https://git.launchpad.net/deja-dup/tree/deja-dup/meson.build#n39 I'd guess this particular case can be solved by moving stuff from By the way, I can't reproduce this problem in Nixpkgs |
Hmm, you are right:
Since meson does not support building in the source directory, would it make sense to modify meson to produce installable tree right in the build directory? Then the linker would use add I would rather not move the internal libraries to lib, too many of moving pieces. I see the line in master: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/tools/build-managers/meson/default.nix#L21-L23 |
According to @dezgeg, the issue with |
I think that patching ELF is a better fit for Meson than passing anything to linker, as it is more in line with Meson behavior and thus more transparent.
You are right, didn't notice it. Also, in reference to #31222: I couldn't reproduce this, even with the same Nixpkgs version. Here's what I've done:
Well, we don't strip a lot of we could, at least not until #31025 gets merged. I think this is the issue @dezgeg refers to: NixOS/patchelf#10. If so, it should be fixed for practical purposes in NixOS/patchelf#117. So, if you use |
I tried adding |
I've spent an hour trying to find a workaround, to no avail. Cross-reference: NixOS/patchelf#10 (comment) |
Given circumstances, I think that not stripping the binaries is OK. However, there is a way around it: from Meson patchelf patch code, if
|
I've implemented the workaround described above in #31436. |
This is based on Jan Tojnar's work in NixOS#31228. When patchelf has to grow rpath beyond original capacity, it sets dontStrip, to work around NixOS/patchelf#10.
Motivation for this change
Some apps require an internal library, that needs to be added to rpath. In 8f95aef, we removed the rpath fixup, breaking these apps.
This commit re-adds the fixup but modifies it to keep the old rpath.
Closes: #31222
Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)