--- C:/users/jeremy/appdata/local/temp/thg.qyvjcu/python-build.1.80827/Lib/distutils/msvc9compiler.py Tue Dec 25 11:26:39 2012 +++ C:/Users/Jeremy/devel/python-build/Lib/distutils/msvc9compiler.py Tue Dec 25 11:26:05 2012 @@ -288,6 +288,20 @@ return result +def get_target_architecture(ccpath): + """Return the target architecture for the compiler. + + Possible results are "80x86", "x64", or "Itanium". + """ + output = subprocess.check_output('"' + ccpath + '"', stderr=subprocess.STDOUT) + output = output.decode('mbcs') + line, tail = output.split('\r\n', 1) + info, arch = line.rsplit(None, 1) + if arch not in ('80x86', 'x64', 'Itanium'): + raise DistutilsPlatformError("Unsupported compiler architecture: %s" % + (arch,)) + return arch + # More globals VERSION = get_build_version() if VERSION < 8.0: @@ -332,7 +346,7 @@ self.__paths = [] # target platform (.plat_name is consistent with 'bdist') self.plat_name = None - self.__arch = None # deprecated name + self.__arch = None self.initialized = False def initialize(self, plat_name=None): @@ -388,6 +402,9 @@ #self.set_path_env_var('lib') #self.set_path_env_var('include') + # determine the target architecture + self.__arch = get_target_architecture(self.cc) + # extend the MSVC path with the current path try: for p in os.environ['path'].split(';'): @@ -398,7 +415,7 @@ os.environ['path'] = ";".join(self.__paths) self.preprocess_options = None - if self.__arch == "x86": + if self.__arch == "80x86": self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/DNDEBUG'] self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', @@ -607,8 +624,18 @@ ldflags = self.ldflags_shared export_opts = [] - for sym in (export_symbols or []): - export_opts.append("/EXPORT:" + sym) + if export_symbols: + for sym in export_symbols: + export_opts.append("/EXPORT:" + sym) + if self.__arch != '80x86': + # The 64-bit linker doesn't mangle the dllexport'ed + # module init function (from PyMODINIT_FUNC) so it causes + # an exported name conflict. We cannot just remove that + # name from export_symbols as the module may not have used + # PyMODINIT_FUNC on its init function. + # + # Supressing the warning is the safest solution. + export_opts.append('/ignore:4197') ld_args = (ldflags + lib_opts + export_opts + objects + ['/OUT:' + output_filename])