[Python-Dev] Linux Python linking with G++?
David Abrahams
dave at boost-consulting.com
Sun Jul 10 15:30:02 CEST 2005
"Martin v. Löwis" <martin at v.loewis.de> writes:
> David Abrahams wrote:
>>>Not entirely. By extending Modules/Setup
>>
>>
>> You mean
>> http://cvs.sourceforge.net/viewcvs.py/python/python/dist/src/Modules/Setup.dist?view=markup
>> ?
>
> I mean Modules/Setup. It is generated from Modules/Setup.dist
> (plus some additional information) in the build process.
>
>> I contend that either:
>>
>> a. Anyone making that sort of extension with a C++ module should
>> explicitly request --with-cxx, or
>>
>> b. The python build system should automatically detect that
>> --with-cxx is needed based on the presence of C++ extension
>> modules.
>>
>> Frankly I think b. would require an impractical amount of work and,
>> speaking as an author of C++ extension modules, I don't think a. is
>> much of a burden to impose.
>
> It is the burden of change.
Well, as you say:
What *has* changed now is that the configure test suddenly determines
that you need to link with g++ on Linux if main was compiled with g++.
This was not the case before, but now is (since g++ 3.2 or something).
> Contributions are welcome.
Let me first try to discover what contribution would be acceptable.
What if:
- we add a configure test that runs after the existing test
determines that --with-cxx is needed (but not when --with-cxx is
explicitly specified on the command line)
- This test runs a 'C' executable that tries to load a C++ dynamic
library with dlopen.
- The test returns an error code if the the dynamic library's static
and dynamic initializers have not been run properly
- If the test fails we disable --with-cxx
??
I'm trying to intrude on the existing behavior as little as possible,
yet get the semantics we want for ELF/Linux in a way that stands a
good chance of generalizing to other platforms.
> However, you will find that with a), people will still pass --with-cxx,
> because they tend to "enable" all features they can find.
That's acceptable to me. We could probably circumvent some of those
cases by improving the configure --help text.
> I personally could accept --with-cxx and ccpython.cc to be removed
> again, but I'm uncertain whether that may break distutils in some
> way.
Well, that would certainly be an easy "solution," but it would break
HP/UX, and it would break anyone that needs to statically link C++
modules on some platforms. It's a much more drastic change than it
would be to only have the system use --with-cxx when the person
running configure asks for it explicitly.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Python-Dev
mailing list