This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients cstratak, fweimer, koobs, vstinner
Date 2019-04-23.15:02:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I'm confused between RPATH and RUNPATH which are *different*.

When I configure Python using LDFLAGS="-Wl,-rpath=/opt/py38/lib/" (Python configure and Makefile), Python, libpython, and dynamic libraries ELF of C extensions get a RPATH.

When I use build_ext -rpath (distutils), dynamic libraries ELF of C extensions get a RUNPATH.

More details below.


When I build lxml using patched Fedora Python (/usr/bin/python3), I get:

$ python3 build_ext --rpath /custom/rpath
$ objdump -a -x build/lib.linux-x86_64-3.7/lxml/|grep -Ei 'rpath|runpath'
  RUNPATH              /custom/rpath

Note: when I use patched Fedora Python, "--rpath /usr/lib64" of "python3 build_ext --rpath /usr/lib64" is ignored: the .so file doesn't have RPATH nor RUNPATH. That's the purpose of the patch.


When I built Python using ./configure --prefix /opt/py38 LDFLAGS="-Wl,-rpath=/opt/py38/lib/" --enable-shared, I got:

$ objdump -a -x /opt/py38/bin/python3.8|grep -i rpath
  RPATH                /opt/py38/lib/
$ objdump -a -x /opt/py38/lib/|grep -i rpath
  RPATH                /opt/py38/lib/

If I build lxml without an explicit rpath, it inherits the Python rpath:

$ LD_LIBRARY_PATH=/opt/py38/lib ./opt_env/bin/python build_ext 
$ objdump -a -x build/lib.linux-x86_64-3.8/lxml/|grep -Ei 'rpath|runpath'
  RPATH                /opt/py38/lib/

If I build lxml with an explicit rpath, I get:

$ LD_LIBRARY_PATH=/opt/py38/lib ./opt_env/bin/python build_ext --rpath /custom/rpath
$ objdump -a -x build/lib.linux-x86_64-3.8/lxml/|grep -Ei 'rpath|runpath'
  RUNPATH              /opt/py38/lib/:/custom/rpath
Date User Action Args
2019-04-23 15:02:44vstinnersetrecipients: + vstinner, koobs, fweimer, cstratak
2019-04-23 15:02:44vstinnersetmessageid: <>
2019-04-23 15:02:44vstinnerlinkissue36659 messages
2019-04-23 15:02:44vstinnercreate