[Pythonmac-SIG] -Wl, -x in distutils module linking causes crashes
Jack Jansen
Jack.Jansen at cwi.nl
Mon Sep 22 18:07:55 EDT 2003
On 22-sep-03, at 23:15, Bob Ippolito wrote:
> You're right, that wasn't very clear. I meant "it's possible to get
> around the -Wl,-x problem by explicitly stating which symbols you
> need", but now that I think about it they're going to be nasty mangled
> C++ crap. However, I did find a workaround, -Wl,-Sn (discard no
> symbols) in extra_link_args will override the -Wl,-x directive.
Now your original statement is clear, but I'm confused about how this
works. Why are non-global symbols important to C++ static
initialization? I hope you're not going to tell me that the runtime
system somehow looks at the symbol table during dynamic loading and
calls all routines whose names fit a certain pattern...
And the "-Wl,-Sn" bit is too much of a hack for my liking. If there is
the possibility of extensions that need non-global symbols to be intact
we should just get rid of -Wl,-x.
>> And if the bind_at_load is needed for C++: is it a good idea to add
>> it to the standard Python Makefile, so distutils will pick it up
>> automatically, or are there adverse consequences to it?
>
> It's only needed for C++ that uses static initializers. Not everybody
> uses these. Can't we detect if C++ is being used and toggle the link
> flags on a per-extension basis when on darwin (append ["-Wl,-Sn",
> "-Wl,-bind_at_load"] to extra_link_flags)? I believe distutils can
> detect the language, because Extension accepts an optional language
> parameter.
Too dangerous. The extension itself could be C, but depend on a C++
library or something.
And counting on C++ users not using a first-class language feature is
also a road I don't
want to go down...
> 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....
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?
--
Jack Jansen, <Jack.Jansen at cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma
Goldman
More information about the Pythonmac-SIG
mailing list