[Python-Dev] Linker problems on Linux

M.-A. Lemburg mal@lemburg.com
Sun, 16 Jul 2000 00:56:33 +0200


Thomas Wouters wrote:
> 
> On Sat, Jul 15, 2000 at 07:57:45PM +0200, M.-A. Lemburg wrote:
> 
> > I just tried to compile the current CVS version on Linux.
> > The compile went fine, but when I started Python, I got:
> 
> > 'import site' failed; use -v for traceback
> > Python 2.0b1 (#1, Jul 15 2000, 19:22:33)  [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> > Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
> > Traceback (most recent call last):
> >   File "/home/lemburg/bin/pyinteractive.py", line 7, in ?
> >     import mx.Tools
> >   File "/home/lemburg/projects/mx/Tools/__init__.py", line 24, in ?
> >     from Tools import *
> >   File "/home/lemburg/projects/mx/Tools/Tools.py", line 10, in ?
> >     from mxTools import *
> >   File "/home/lemburg/projects/mx/Tools/mxTools/__init__.py", line 1, in ?
> >     from mxTools import *
> > ImportError: /home/lemburg/projects/mx/Tools/mxTools/mxTools.so: undefined symbol: PyObject_Length
> 
> > Why isn't PyObject_Length being exported anymore ???
> 
> PyObject_Length is changed into a #define, to PyObject_Size. This preserves
> the API but not the ABI ;) GCC has a construct to make one function an alias
> for another:
> 
> PyObject * PyObject_Length() __attribute__((alias("PyObject_Size")));
> 
> But this is not likely to work in other compilers, and not on all
> architectures to start with. The most portable solution is probably to make
> PyObject_Length() a wrapper for PyObject_Size, and hope the compiler knows
> how to handle that most efficiently.

Right, there will have to be an exported API PyObject_Length() which
then does nothing other than to call PyObject_Size(). There's an
example of how this can be done in ceval.c (see the PyEval_CallObject()
API).

Why hasn't anyone objected to simply dropping such an important
API without proper backwards compatibility workaround ?

The situation on Windows is already bad enough with extensions
compiled against 1.5 causing a segfault...

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/