The new msvc9compiler module supports VS 2005 and VS 2008. I've also fixed build_ext to support PCbuild8 and PCbuild9 and backported my fix for xxmodule.c from py3k. The old code msvccompiler is still in place in case somebody likes to build an extension with VS 2003 or earlier.
I've also updated the cygwin compiler module for VS 2005 and VS 2008. It works with VS 2005 but I'm unable to test it with VS 2008. We have to wait for a new version of cygwin.
After some more reflection (and no negative feedback), I am reverting the
original patch and applying my version, cygwinccompiler.py-shared.diff,
instead.
My reasons are the following:
1. support for older toolchains is retained
2. support for new toolchains (i.e., ld -shared) is added
The goal of my approach is to avoid breaking older toolchains while adding
better support for newer ones.
The cygwinccompiler.get_versions() function only handles versions numbers of
the form "x.y.z". The attached patch enhances get_versions() to handle "x.y"
too (i.e., the ".z" is optional).
This change causes the unnecessary "--entry _DllMain@12" link option to be
suppressed for recent Cygwin and Mingw toolchains. Additionally, it directs
recent Mingw toolchains to use gcc instead of dllwrap during linking.
Currently, the cygwinccompiler.py compiler handling in
distutils is invoking the cygwin and mingw compilers
with the -static option.
Logically, this means that the linker should choose to
link to static libraries instead of shared/dynamically
linked libraries.
Current win32 binutils expect import libraries to have
a .dll.a suffix and static libraries to have .a suffix.
If -static is passed, it will skip the .dll.a
libraries. This is pain if one has a tree with both
static and dynamic libraries using this naming
convention, and wish to use the dynamic libraries.
The -static option being passed in distutils is to get
around a bug in old versions of binutils where it would
get confused when it found the DLLs themselves.
The decision to use static or shared libraries is site
or package specific, and should be left to the setup
script or to command line options.
[#413582] g++ must be called for c++ extensions
[#454030] distutils cannot link C++ code with GCC
topdir = "Lib/distutils"
* bcppcompiler.py
(BCPPCompiler.create_static_lib): Fixed prototype, removing extra_preargs
and extra_postargs parameters. Included target_lang parameter.
(BCPPCompiler.link): Included target_lang parameter.
* msvccompiler.py
(MSVCCompiler.create_static_lib): Fixed prototype, removing extra_preargs
and extra_postargs parameters. Included target_lang parameter.
(MSVCCompiler.link): Included target_lang parameter.
* ccompiler.py
(CCompiler): New language_map and language_order attributes, used by
CCompiler.detect_language().
(CCompiler.detect_language): New method, will return the language of
a given source, or list of sources. Individual source language is
detected using the language_map dict. When mixed sources are used,
language_order will stablish the language precedence.
(CCompiler.create_static_lib, CCompiler.link, CCompiler.link_executable,
CCompiler.link_shared_object, CCompiler.link_shared_lib):
Inlcuded target_lang parameter.
* cygwinccompiler.py
(CygwinCCompiler.link): Included target_lang parameter.
* emxccompiler.py
(EMXCCompiler.link): Included target_lang parameter.
* mwerkscompiler.py
(MWerksCompiler.link): Included target_lang parameter.
* extension.py
(Extension.__init__): New 'language' parameter/attribute, initialized
to None by default. If provided will overlap the automatic detection
made by CCompiler.detect_language(), in build_ext command.
* sysconfig.py
(customize_compiler): Check Makefile for CXX option, and also the
environment variable CXX. Use the resulting value in the 'compiler_cxx'
parameter of compiler.set_executables().
* unixccompiler.py
(UnixCCompiler): Included 'compiler_cxx' in executables dict, defaulting
to 'cc'.
(UnixCCompiler.create_static_lib): Included target_lang parameter.
(UnixCCompiler.link): Included target_lang parameter, and made
linker command use compiler_cxx, if target_lang is 'c++'.
* command/build_ext.py
(build_ext.build_extension): Pass new ext.language attribute
to compiler.link_shared_object()'s target_lang parameter. If
ext.language is not provided, detect language using
compiler.detect_language(sources) instead.
* command/config.py
(config._link): Pass already available lang parameter as target_lang
parameter of compiler.link_executable().
Always use _setup_compile() to do the grunt work of processing
arguments, figuring out which files to compile, and emitting debug
messages for files that are up-to-date.
Use _get_cc_args() when possible.
This is a conservative version of SF patch 504889. It uses the log
module instead of calling print in various places, and it ignores the
verbose argument passed to many functions and set as an attribute on
some objects. Instead, it uses the verbosity set on the logger via
the command line.
The log module is now preferred over announce() and warn() methods
that exist only for backwards compatibility.
XXX This checkin changes a lot of modules that have no test suite and
aren't exercised by the Python build process. It will need
substantial testing.
implementations. Details:
* replace 'link_shared_object()', 'link_shared_lib()', and
'link_executable()' with 'link()', which is (roughly)
the union of the three methods it replaces
* in all implementation classes (UnixCCompiler, MSVCCompiler, etc.),
ditch the old 'link_*()' methods and replace them with 'link()'
* in the abstract base class (CCompiler), add the old 'link_*()'
methods as wrappers around the new 'link()' (they also print
a warning of the deprecated interface)
Also increases consistency between MSVCCompiler and BCPPCompiler,
hopefully to make it easier to factor out the mythical WindowsCCompiler
class. Details:
* use 'self.linker' instead of 'self.link'
* add ability to compile resource files to BCPPCompiler
* added (redundant?) 'object_filename()' method to BCPPCompiler
* only generate a .def file if 'export_symbols' defined
* use self.debug_print() for debug messages
* uses now copy.copy() to copy lists
* added 'shared_lib_extension=".dll"', ... , this is necessary if you
want use the compiler class outside of the standard distutils build
process.
* changed result type of check_config_h() from int to string
- added big comment describing possible problems
- look for and react to versions of gcc, ld, and dlltool; mainly
this is done by the 'get_versions()' function and the CygwinCCompiler
and Mingw32CCompiler constructors
- move 'check_config_h()' to end of file and defer calling it until
we need to (ie. in the CygwinCCompiler constructor)
- lots of changes in 'link_shared_object()' -- mostly seems to be
library and DLL stuff, but I don't follow it entirely
major ports of GCC to Windows. Contributed by Rene Liebscher, and quite
untested by me. Apparently requires tweaking Python's installed config.h
and adding a libpython.a to build extensions.