[issue36659] distutils UnixCCompiler: Remove standard library path from rpath

STINNER Victor report at bugs.python.org
Tue Apr 23 07:26:08 EDT 2019


STINNER Victor <vstinner at redhat.com> added the comment:

My understanding of Fedora 00001-rpath.patch is that it ignores -rpath PATH option passed to the setup.py bdist command if PATH is equal to Python sysconfig LIBDIR variable. So it impacts how third party C extensions are built. On my Fedora, LIBDIR is set to:

$ python3 -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))"
/usr/lib64

Only LIBDIR directory is ignored: other -rpath directories are passed to the linker.

---

UnixCCompiler.link() has a runtime_library_dirs parameter which can be modified by the _fix_lib_args() method and then is passed to gen_lib_options().

gen_lib_options() calls compiler.runtime_library_dir_option() on each directory of runtime_library_dirs: this part is responsible to use the proper linker option: -R, -rpath, -L, etc.

build_ext.build_extension() method of distutils.commands.build_ext pass Extension.runtime_library_dirs to compiler.link_shared_object()

build_ext.check_extensions_list() modify the runtime_library_dirs attribute:

    # Medium-easy stuff: same syntax/semantics, different names.
    ext.runtime_library_dirs = build_info.get('rpath')

I understand that build_info.get('rpath') comes from -rpath command line option of setup.py bdist_ext command:

        ('rpath=', 'R',
         "directories to search for shared C libraries at runtime"),

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36659>
_______________________________________


More information about the Python-bugs-list mailing list