-
Notifications
You must be signed in to change notification settings - Fork 21
spin build should fix the rpath for shared libaries #176
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
Comments
Since editable installs already work for you, gh-155 to make editable installs work with For the default
This is probably not the relevant code, because it's about internal shared libraries, while the ones you have are external (not built as part of the Normally Meson will take care of rpath rewriting during install. It's possible that that doesn't work for in-tree shared libraries because they're not considered external. Does it work without The entries should have absolute paths for shared library dependencies that are not on the default loader search path. For example:
RPATH entry:
|
Yes, that's correct. This is what I get from # build dir
$ ldd build/src/flint/types/fmpz.cpython-312-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffd673d8000)
libflint.so.19 => /home/oscar/current/active/python-flint/build/src/flint/types/../../../../.local/lib/libflint.so.19 (0x0000737a77000000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000737a76c00000)
libmpfr.so.6 => /home/oscar/current/active/python-flint/.local/lib/libmpfr.so.6 (0x0000737a76800000)
libgmp.so.10 => /home/oscar/current/active/python-flint/.local/lib/libgmp.so.10 (0x0000737a76f5b000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x0000737a76e74000)
/lib64/ld-linux-x86-64.so.2 (0x0000737a77c8f000)
# install dir
$ ldd build-install/usr/lib/python3.12/site-packages/flint/types/fmpz.cpython-312-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007ffef73fd000)
libflint.so.19 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x0000709664000000)
/lib64/ld-linux-x86-64.so.2 (0x000070966440b000) This is what $ readelf -d build/src/flint/types/fmpz.cpython-312-x86_64-linux-gnu.so
Dynamic section at offset 0x41cc8 contains 26 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libflint.so.19]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../../../.local/lib]
0x000000000000000c (INIT) 0x6000
0x000000000000000d (FINI) 0x37de4
0x0000000000000019 (INIT_ARRAY) 0x42cb8
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
0x000000000000001a (FINI_ARRAY) 0x42cc0
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x2f0
0x0000000000000005 (STRTAB) 0x1878
0x0000000000000006 (SYMTAB) 0x318
0x000000000000000a (STRSZ) 4012 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x43000
0x0000000000000002 (PLTRELSZ) 4392 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x4ad8
0x0000000000000007 (RELA) 0x2a20
0x0000000000000008 (RELASZ) 8376 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0x29f0
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x2824
0x000000006ffffff9 (RELACOUNT) 306
0x0000000000000000 (NULL) 0x0
$ readelf -d build-install/usr/lib/python3.12/site-packages/flint/types/fmpz.cpython-312-x86_64-linux-gnu.so
Dynamic section at offset 0x41cc8 contains 25 entries:
Tag Type Name/Value
0x0000000000000001 (NEEDED) Shared library: [libflint.so.19]
0x0000000000000001 (NEEDED) Shared library: [libc.so.6]
0x000000000000000c (INIT) 0x6000
0x000000000000000d (FINI) 0x37de4
0x0000000000000019 (INIT_ARRAY) 0x42cb8
0x000000000000001b (INIT_ARRAYSZ) 8 (bytes)
0x000000000000001a (FINI_ARRAY) 0x42cc0
0x000000000000001c (FINI_ARRAYSZ) 8 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x2f0
0x0000000000000005 (STRTAB) 0x1878
0x0000000000000006 (SYMTAB) 0x318
0x000000000000000a (STRSZ) 4012 (bytes)
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x43000
0x0000000000000002 (PLTRELSZ) 4392 (bytes)
0x0000000000000014 (PLTREL) RELA
0x0000000000000017 (JMPREL) 0x4ad8
0x0000000000000007 (RELA) 0x2a20
0x0000000000000008 (RELASZ) 8376 (bytes)
0x0000000000000009 (RELAENT) 24 (bytes)
0x000000006ffffffe (VERNEED) 0x29f0
0x000000006fffffff (VERNEEDNUM) 1
0x000000006ffffff0 (VERSYM) 0x2824
0x000000006ffffff9 (RELACOUNT) 306
0x0000000000000000 (NULL) 0x0 I'm not sure why I have an extra usr like
I don't think I've set that anywhere though... |
Yep, this being a relative rather than an absolute path should be the problem.
That's the output of |
No, it still doesn't work in that case. I just get an extra
|
To be clear I used an absolute path to a directory outside of the working directory
but it somehow got turned into a relative path. |
So cutting out spin then the problem is just: $ PKG_CONFIG_PATH=$(pwd)/.local/lib/pkgconfig meson setup build
$ meson compile -C build
$ readelf -d build/src/flint/types/fmpz.cpython-312-x86_64-linux-gnu.so | grep RUNPATH
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN/../../../../.local/lib] We wanted an absolute path to be in the binary but we've been left with a relative one. Should that be considered a bug in meson? |
It all works fine on macos so I'm only seeing this problem on Linux. |
@oscarbenjamin If I understand this issue correctly, this is a Meson problem. If you agree, we can close this, otherwise I can investigate further. |
Yeah, this is just a meson issue I think. |
The solution to this (mesonbuild/meson#13046 (comment)) is to set
Possibly it would be useful for spin to add a more discoverable CLI option for that like
In flintlib/python-flint#135 I added a custom option
The |
From the discussion in mesonbuild/meson#13046 I think that this is sort of a |
I think it's specific to "build against a shared library that's not on the default loader search path", and is unrelated to the install location. I.e., whether you use |
I'm migrating python-flint to meson-python and testing out spin as a frontend (flintlib/python-flint#129).
The setup that I use with python-flint is to build libraries with
--prefix=$(pwd)/.local
so that I have isolated builds of the C dependencies inside the python-flint development checkout.When building wheels with meson-python I can set
PKG_CONFIG_PATH
to find the libraries and then meson-python fixes the rpath:https://github.com/mesonbuild/meson-python/blob/c9d1c2dafb54692ad56dcda1bc67fd52b83b29c0/mesonpy/__init__.py#L431-L440
This means that I can do e.g.
However
spin build
does not fix the rpath and sospin test
does not work unless I setLD_LIBRARY_PATH
:I think that
spin build
should set the rpath somehow but I'm not sure where is the place that this should be fixed. I assume that it would be out of place for spin to manipulate the rpath entries directly like meson-python does.Should meson set the rpath?
Should spin ask meson or meson-python to do it somehow?
The text was updated successfully, but these errors were encountered: