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 vstinner
Date 2019-04-23.10:07:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1556014023.54.0.449571197372.issue36659@roundup.psfhosted.org>
> ... Now, I'm confused. Is PR 12876 useless? Was distutils already fixed?

My test was wrong, objdump sometimes uses "RUNPATH", sometimes "RPATH":

$ objdump -a -x build/lib.linux-x86_64-*/lxml/etree.cpython-*-x86_64-linux-gnu.so|grep -i -E 'rpath|RUNPATH'
  RUNPATH              /opt/py38/lib

Wait, they are not the same. Now I'm confused :-)

More doc about RPATH and RUNPATH:


"An additional source of confusion is that, depending on your distribution, the -rpath argument in ‘ld’ behaves differently. For some it generates a DT_RPATH and for others DT_RPATH and DT_RUNPATH."

Unless loading object has RUNPATH:
    RPATH of the loading object,
        then the RPATH of its loader (unless it has a RUNPATH), ...,
        until the end of the chain, which is either the executable
        or an object loaded by dlopen
    Unless executable has RUNPATH:
        RPATH of the executable
RUNPATH of the loading object
default dirs

I'm now also confused by 

UnixCCompiler.runtime_library_dir_option() of distutils.unixccompiler which starts with a long comment:

# XXX Hackish, at the very least.  See Python bug #445902:
# http://sourceforge.net/tracker/index.php
#   ?func=detail&aid=445902&group_id=5470&atid=105470
# Linkers on different platforms need different options to
# specify that directories need to be added to the list of
# directories searched for dependencies when a dynamic library
# is sought.  GCC on GNU systems (Linux, FreeBSD, ...) has to
# be told to pass the -R option through to the linker, whereas
# other compilers and gcc on other systems just know this.
# Other compilers may need something slightly different.  At
# this time, there's no way to determine this information from
# the configuration data stored in the Python installation, so
# we use this hack.

Linux code path:

if self._is_gcc(compiler):
    # gcc on non-GNU systems does not need -Wl, but can
    # use it anyway.  Since distutils has always passed in
    # -Wl whenever gcc was used in the past it is probably
    # safest to keep doing so.
    if sysconfig.get_config_var("GNULD") == "yes":
        # GNU ld needs an extra option to get a RUNPATH
        # instead of just an RPATH.
        return "-Wl,--enable-new-dtags,-R" + dir
        return "-Wl,-R" + dir
    # No idea how --enable-new-dtags would be passed on to
    # ld if this system was using GNU ld.  Don't know if a
    # system like this even exists.
    return "-R" + dir

When GCC is detected on Linux and GNULD sysconfig variable is equal to "yes", distutils uses "-Wl,--enable-new-dtags,-R <path>" rather than "-Wl,-R <path>" or just "-R <path>".

See also https://wiki.debian.org/RpathIssue
Date User Action Args
2019-04-23 10:07:03vstinnersetrecipients: + vstinner
2019-04-23 10:07:03vstinnersetmessageid: <1556014023.54.0.449571197372.issue36659@roundup.psfhosted.org>
2019-04-23 10:07:03vstinnerlinkissue36659 messages
2019-04-23 10:07:02vstinnercreate