classification
Title: Ensure RUNPATH is added to extension modules with RPATH if GNU ld is used
Type: behavior Stage:
Components: Distutils Versions: Python 3.1, Python 2.7
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: tarek Nosy List: flub, tarek
Priority: normal Keywords: patch

Created on 2009-05-01 22:56 by flub, last changed 2009-05-09 11:56 by tarek. This issue is now closed.

Files
File name Uploaded Description Edit
runpath.diff flub, 2009-05-01 22:56 Add RUNPATH if RPATH is requested and GNU ld is used
Messages (6)
msg86924 - (view) Author: Floris Bruynooghe (flub) Date: 2009-05-01 22:56
The build_ext command does accept a handy --rpath option to encode an
RPATH in the built extension modules.  However RPATH is superseded by
RUNPATH since the former can not be overwritten by the LD_LIBRARY_PATH
environment varialbe, while the later can.  While most linkers will add
a RUNPATH automatically when you ask for an RPATH, GNU ld does not do
this.  Therefore this patch does detect if GNU ld is used and if so will
use the --enable-new-dtags option which will add the RUNPATH.
msg87126 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-04 13:54
what about adding 'GNULD' into sysconfig.customize_compiler too, so it
can be set using os.environ as well, not only in the Makefile
msg87134 - (view) Author: Floris Bruynooghe (flub) Date: 2009-05-04 15:21
I'm not convinced that would help much.  The GNULD variable in the
makefile is for when the default linker is used.  If you change that by
using LDSHARED then you're probably not going to be using --rpath but
LDFLAGS to configure it the way you want.

If anything maybe using configure/Makefile to detect if GNU ld is used
is wrong just for the case they use LDSHARED (I didn't think of this
before), since then they can use LDSHARED and --rpath and get misterious
failures.  But it seems a lot more complicated to do, LDSHARED can be
set to something like "cc -shared" (the default) in which case we can't
use -V and assume it's a non-GNU ld if we don't get "GNU" back.  So we'd
have to try and detect if LDSHARED is set to a compiler or a linker,
then try to find which linker gets invoked etc.  A lot more complicated
and way more possibilities then I can test.

I'd argue that when someone uses LDSHARED they should be using LDFLAGS
intead of --rpath, they obviously know what they are doing.  --rpath is
there if you want to use the environment Python was compiled in to build
an extension module with a RPATH/RUNPATH in.
msg87485 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-09 08:03
I including the patch right now. I a changing minor things (adding the
missing configure and renaming tests)
msg87486 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-09 08:30
done in r72497 in trunk. (tests run under macos, debian and win)

I'll wait 2 hours to watch the buildbots then I'll propagate it to the
py3k branch
msg87491 - (view) Author: Tarek Ziadé (tarek) * (Python committer) Date: 2009-05-09 11:56
done in py3k in r72504


Thanks Floris !
History
Date User Action Args
2009-05-09 11:56:20tareksetstatus: open -> closed

messages: + msg87491
2009-05-09 08:30:59tareksetmessages: + msg87486
2009-05-09 08:03:23tareksetmessages: + msg87485
versions: + Python 3.1
2009-05-04 15:21:37flubsetmessages: + msg87134
2009-05-04 13:54:36tareksetmessages: + msg87126
2009-05-01 22:56:03flubcreate