[Python-Dev] Linux Python linking with G++?

David Abrahams dave at boost-consulting.com
Mon Jul 11 00:51:55 CEST 2005


"Martin v. Löwis" <martin at v.loewis.de> writes:

> David Abrahams wrote:
>>   - 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
>> 
>> ??
>
> What would be the purpose of such a test? The test may fail for many
> reasons, for example, dlopen might not be available.

I was assuming we only disable --with-cxx if the test builds
successfully.  I presume dlopen will fail linking if it's unavailable?

> OTOH, on current Linux systems the test would succeed, so configure
> would conclude to link with g++.

Uhh, whoops. Change the sense of my last bullet

   - If the test passes 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.
>
> I now think that the code should be made more simple, not more complex.
> Aspects of a solution I could accept:
>
> - ccpython.cc and linking with g++ is removed entirely. or,

That would be bad for C++ users on HP/UX.  Is that acceptable?

> - the logic is fixed so that linking with g++ is only done if
>   main is in ccpython.o

I don't see how that works.  Somehow we need to decide whether to put
main in ccpython.o in the first place, don't we?

> - the configure test is extended to better match current g++
>   behaviour.

What do you have in mind?

>> 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.
>
> I just checked, and it seems that the logic in use is still somewhat
> different. If the configure test determines that a C++ main()
> must be linked with CXX, it unconditionally changes the linker to CXX.
> The test, in turn, is run always if a C++ compiler was found,
> i.e. independently of whether --with-cxx was provided.

That doesn't match up with reports from my testers who say they can
run with C++ extension modules from many different GCC versions if
they just configure their Python --without-cxx.  If what you were
saying were true, wouldn't --without-cxx be ignored on ELF/Linux?

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com


More information about the Python-Dev mailing list