Skip to content
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

Wrong rpath after repair #257

Open
ozon2 opened this issue Aug 7, 2020 · 4 comments
Open

Wrong rpath after repair #257

ozon2 opened this issue Aug 7, 2020 · 4 comments
Labels

Comments

@ozon2
Copy link

ozon2 commented Aug 7, 2020

I am using auditwheel 3.2.0 on manylinux2014_x86_64 docker and after running auditwheel repair on my wheel the rpath of a shared library is set to a wrong value.

When i install the wheel created by auditwheel i get this tree:

/usr/local/lib/python3.6/site-packages/
├── example_adder
│   ├── __init__.py
│   └── libexample_adder.so
├── gepetto_example_adder.libs
│   ├── libboost_python3-mt-1ace0776.so.1.53.0
│   └── libexample-adder-f1ca4966.so.3.0.2-1-g0463-dirty

So the rpath of libexample_adder.so should be set to $ORIGIN/../gepetto_example_adder.libs, however auditwheel set a wrong rpath:

readelf -d /usr/local/lib/python3.6/site-packages/example_adder/libexample_adder.so| grep 'R.*PATH'
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/../../../../../../gepetto_example_adder.libs]
@lkollar
Copy link
Contributor

lkollar commented Aug 7, 2020

This might be related to #245. Could you check if it happens with 3.1.1 as well? Is the code available somewhere to try to reproduce the issue?

@ozon2
Copy link
Author

ozon2 commented Aug 8, 2020

It happens on 3.1.1 as well.

Here is how to create the same wheel:

git clone --recursive https://github.com/Ozon2/example-adder.git
cd example-adder
git checkout dad2314
docker build . -t example-adder-manylinux
docker run --rm -it -e PLAT=manylinux2014_x86_64 -v `pwd`:/io example-adder-manylinux bash
./build_wheels.sh

I can't test it directly on the manylinux docker because for some reason it installs the shared libraries in /usr/local/lib64/python3.6/site-packages/gepetto_example_adder.libs instead of /usr/local/lib/python3.6/site-packages/gepetto_example_adder.libs.

You can reproduce the issue on another docker with:

docker run --rm -it -v `pwd`:/io python:3.6.11-buster bash
/io/test_wheels.sh
readelf -d /usr/local/lib/python3.6/site-packages/example_adder/libexample_adder.so| grep 'R.*PATH'
find / -name gepetto_example_adder.libs

mayeut added a commit to mayeut/auditwheel that referenced this issue Nov 8, 2020
It would be better to rebuild the sample from source not to lose it when python 3.6 is dropped but it's a bit complex to rebuild in a generic way.
mayeut added a commit to mayeut/auditwheel that referenced this issue Nov 8, 2020
It would be better to rebuild the sample from source to get it for all images but it's a bit complex to rebuild in a generic way.
@mayeut
Copy link
Member

mayeut commented Nov 11, 2020

Auditwheel is putting grafted libraries at the root of the wheel:

with InWheelCtx(wheel_path) as ctx:
ctx.out_wheel = pjoin(out_dir, wheel_fname)
match = WHEEL_INFO_RE(wheel_fname)
if not match:
raise ValueError("Failed to parse wheel file name: %s",
wheel_fname)
dest_dir = match.group('name') + lib_sdir
if not exists(dest_dir):
os.mkdir(dest_dir)

It assumes 2 things:

  • 'Root-Is-Purelib' == False: this seems OK as it changes this value to False when deemed necessary
  • All modules are placed in root: this is wrong. According to PEP427, there are multiple places where things can go and this is where things go badly here.

Files can go in:

  • root with destination being defined by Root-Is-Purelib (always False) so platlib
  • {distribution}-{version}.data/(purelib|platlib|headers|scripts|data)

Here, skbuild has chosen to put all files in {distribution}-{version}.data/data e.g. ./gepetto_example_adder-3.0.2.data/data/lib/python3.7/site-packages/example_adder/libexample_adder.so.
This means RPATH is computed between ./gepetto_example_adder-3.0.2.data/data/lib/python3.7/site-packages/example_adder/libexample_adder.so and ./gepetto_example_adder.libs/libexample-adder-21dabdd7.so.3.0.2-6-gd319 instead of ./example_adder/libexample_adder.so and ./gepetto_example_adder.libs/libexample-adder-21dabdd7.so.3.0.2-6-gd319

That being said, I don't know the exact implications between the different destination directories allowed and how auditwheel should manage them. If every grafted library is grafted for only one destination directory, should be pretty easy to manage however, if it crosses multiple directories, that's another story. (I'm specifically thinking of the scripts vs platlib which I guess could be pretty common).

@mayeut mayeut added the bug label Dec 13, 2020
mayeut added a commit to mayeut/auditwheel that referenced this issue Feb 6, 2021
It would be better to rebuild the sample from source to get it for all images but it's a bit complex to rebuild in a generic way.
mayeut added a commit to mayeut/auditwheel that referenced this issue Mar 6, 2021
It would be better to rebuild the sample from source to get it for all images but it's a bit complex to rebuild in a generic way.
mayeut added a commit to mayeut/auditwheel that referenced this issue Mar 6, 2021
It would be better to rebuild the sample from source to get it for all images but it's a bit complex to rebuild in a generic way.
@brenthuisman
Copy link

brenthuisman commented Jan 13, 2022

Wrote a small script that patches the rpaths in our wheels post auditwheel. In case you're interested, it's easily adapted for your situation: https://github.com/arbor-sim/arbor/blob/3dc2f266ecb09e535ab35d878fd3a8375e7d2fa8/scripts/patchwheel.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants