[Pythonmac-SIG] -Wl, -x in distutils module linking causes crashes

Nicholas Riley njriley at uiuc.edu
Mon Sep 22 19:20:31 EDT 2003


On Tue, Sep 23, 2003 at 12:07:55AM +0200, Jack Jansen wrote:
> >  Also, a typical C++ program will probably link to stdc++, which 
> >could be an alternative trigger for linking special behavior.
> 
> Hmm, this is interesting. I've noticed that adding "-lstdc++" solved 
> some problems. But from your example not all problems, as in your Mk4py 
> you also added the bind_at_load magic....

-bind_at_load is not necessary when a two-level namespace is used.

> Hmm again: is all this strangeness Apple-specific, or is it a general 
> GCC C++ problem? I.e. on other platforms, can people get away with 
> linking extensions that may have some C++ code in them normally, or is 
> there always magic involved?

This part at least is Mac OS X-specific, a quirk of dyld seemingly.

Adding -lstdc++, or linking with g++ instead of gcc, fixed the build
process for Metakit on Linux.  There is an -x option to GNU ld, but it
isn't used by the standard Python installation there, and when I
manually added it, it appeared to have no effect on the functionality
of Mk4py.

The only flag passed to the compiler/linker by distutils on Linux is
-shared.  Without g++/libstdc++ on Linux, you get an error:

../builds/lib.linux-i686-2.2/Mk4py.so: undefined symbol: _Unwind_Resume

The basic problem is the lack of provision in distutils for specifying
a different compiler for C++.  Some parts of the framework support it,
but others don't.  I've read through many discussions of this on the
distutils-sig list, going back several years.  Most concluded that if
you wanted distutils to use a C++ compiler for your extension modules,
then Python itself should be compiled with that compiler.  That wasn't
acceptable to some people, so hacks were proposed to fool distutils
into using a different compiler, and I implemented something based on
one of these hacks.

Would removal of -Wl,-x adversely affect performance of Python?  If
so, perhaps I (or someone) need to take this up on darwin-development
or similar.

-- 
=Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>



More information about the Pythonmac-SIG mailing list