[Patches] [ python-Patches-412229 ] runtime RTLD_NOW control via sys

noreply@sourceforge.net noreply@sourceforge.net
Thu, 07 Jun 2001 07:34:44 -0700


Patches item #412229, was updated on 2001-03-29 08:55
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=412229&group_id=5470

Category: core (C code)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Bram Stolk (bram)
Assigned to: Martin v. Löwis (loewis)
Summary: runtime RTLD_NOW control via sys

Initial Comment:
This patch enables runtime control over the RTLD_NOW
flag, which can be used to do lazy symbol resolving
when loading a shared lib.

It's an extention to the sys module:
sys.setlazysymresolve(0|1)

The patch is against the latest CVS code, and
was generated by 'cvs diff'.

----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2001-06-07 07:34

Message:
Logged In: YES 
user_id=21627

The patch looks good to me now, so I recommend accepting it
- except for the part that activates dlmodule by default.

As for getting at the RTLD flags, I see three options:
1. setup.py could be changed to build dl wherever possible.
2. Administrators should activate dlmodule if they trust it.
3. Application authors somehow need to find out the values
of RTLD_ on their system, e.g. by per-system hard-coded
values, or by running h2py on dlfcn.h; that could be part of
the Python distribution for systems known to support
dlfcn.h.
3. the RTLD_ flags are exported from some other module as
well;
    imp comes to mind.

Actually, putting setdlopenflags into imp instead of sys
might be worth a consideration.

----------------------------------------------------------------------

Comment By: Bram Stolk (bram)
Date: 2001-06-07 03:52

Message:
Logged In: YES 
user_id=14028

Ok,  I've revised the patch as you suggested.
Currently, you can get and set the flags just as you
specified.
Also, it should also build on platforms without RTLD_NOW,
and even on platforms without LDOPEN altogether.

However, I see one problem with this:
After Python 1.5.2, the dl module seems to be removed from
the
default installation. 

This means that dl.RTLD_NOW and dl.RTLD_LAZY are not
readilly available on a standard Python install.
This is akward.

The patch was generated with the command:
cvs diff -c against the cvs tree of  Thu Jun  7 12:44:18 MDT
2001

   Bram


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2001-06-05 23:39

Message:
Logged In: YES 
user_id=21627

The patch needs further work: The code currently compiles 
on systems which don't define RTLD_NOW (although I'm not 
sure what these systems are); your code doesn't.

Also, the code allows to set the flags, but has no 
interface to query them.

Finally, users often complain that Python should use 
RTLD_GLOBAL, so that they can share symbols across 
extension modules. Therefore, I propose that you allow 
setting arbitrary dlopen flags; users would have to write

sys.setdlopenflags(0)

to turn off RTLD_NOW, and use

sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)

to add RTLD_GLOBAL.

When you revise this patch, please submit unified (-u) or 
context (-c) diffs.


----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-04-10 14:48

Message:
Logged In: YES 
user_id=6380

Sorry, no new features in 2.1.

I'll look at this after 2.1 is released though.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=305470&aid=412229&group_id=5470