question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hard-coded RPATH in libraries

See original GitHub issue

When I run pip install cocotb==1.4.0rc1 in one conda environment, it builds and installs a wheel and saves the wheel in a cache. Now, when I run the same command in a new conda environment, it reuses the wheel. The problem is that the .so files have a hard-coded RPATH to the first environment, so when that env is deleted, cocotb breaks in the other env.

From what I can tell, conda solves this problem for its packages: https://docs.conda.io/projects/conda-build/en/latest/resources/make-relocatable.html

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:50 (50 by maintainers)

github_iconTop GitHub Comments

2reactions
mtikekarcommented, Jun 24, 2020

Yes, all extension modules built with setuptools/distutils will have this rpath. The difference is that they are being loaded by python which has already loaded libpython. So these extension modules don’t really care for having the right rpath.

You can check by building some simple extension modules like https://github.com/starnight/python-c-extension. This is the compile command it runs:

gcc -pthread -shared -B /home/mtikekar/.conda/envs/foo/compiler_compat -L/home/mtikekar/.conda/envs/foo/lib \
-Wl,-rpath=/home/mtikekar/.conda/envs/foo/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.7/bind.o \
build/temp.linux-x86_64-3.7/libmypy.o -o build/lib.linux-x86_64-3.7/helloworld.cpython-37m-x86_64-linux-gnu.so

You can see the -Wl,-rpath but no -lpython.

For cocotb, libcocotb is loaded by the simulator which then has to load libpython. That is source of the problem here.

1reaction
ktbarrettcommented, Jun 27, 2020

I opened a discussion on pypa’s discourse to maybe get some more experienced eyes on the problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remove hardcoded rpath from c executable in Makefile
When I build the executable, the linker(LD) sets the executable RPATH to the path of local shared libraries in the compilation environment.
Read more >
RPATH - run-time search path hard-coded in native library
RPATH - run-time search path hard-coded in native library - hpAndro Vulnerable Application Challenge ; CTF Link : http://ctf.hpandro.
Read more >
rpath - Wikipedia
In computing, rpath designates the run-time search path hard-coded in an executable file or library. Dynamic linking loaders use the rpath to find...
Read more >
Creating relocatable Linux executables by setting RPATH with ...
RPATH stands for run-time search path. According to Wikipedia, “rpath designates the run-time search path hard-coded in an executable file or library.
Read more >
Hardcoded shared library locations: How can I override them?
You could try chrpath, seems to fit the bill. Else you can add an LD_PRELOAD entry for every library that is rpath'd. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found