[Python-Dev] [C++-sig] GCC version compatibility
Nicholas Bastin
nick.bastin at gmail.com
Tue Jul 12 17:20:39 CEST 2005
On 7/12/05, Christoph Ludwig <cludwig at cdc.informatik.tu-darmstadt.de> wrote:
> If distutils builds C++ extensions with the C compiler then I consider this a
> bug in distutils because it is unlikely to work. (Unless the compiler can
> figure out from the source file suffixes in the compilation step *and* some
> info in the object files in the linking step that it is supposed to act like a
> C++ compiler. None of the compilers I am familiar with does the latter.)
> distutils should rather look for a C++ compiler in the PATH or explicitly ask
> the user to specify the command that calls the C++ compiler.
You practically always have to use --compiler with distutils when
building C++ extensions anyhow, and even then it rarely does what I
would consider 'The Right Thing(tm)'. The problem is the distutils
core assumption that you want to build extension modules with the same
compiler options that you built Python with, is in many cases the
wrong thing to do for C++ extension modules, even if you built Python
with --with-cxx. This is even worse on windows where the MSVC
compiler, until very recently, was crap for C++, and you really needed
to use another compiler for C++, but Python was always built using
MSVC (unless you jumped through hoops of fire).
The problem is that this is much more complicated than it seems - you
can't just ask the user for the C++ compiler, you really need to
provide an abstraction layer for all of the compiler and linker flags,
so that a user could specify what those flags are for their compiler
of choice. Of course, once you've done that, the user might as well
have just written a new Compiler class for distutils, which wouldn't
pay any attention to how Python was built (other than where Python.h
is).
--
Nick
More information about the Python-Dev
mailing list