[ctypes-commit] ctypes setup.py,1.136,1.137
Brought to you by:
theller
From: Thomas H. <th...@us...> - 2006-03-27 18:39:58
|
Update of /cvsroot/ctypes/ctypes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4775 Modified Files: setup.py Log Message: Fixes from Khalid A. Bakr for MingW compiling ctypes. He writes: I have made some changes (see attached diff) to the setup.py to have MinGW pass the "--enable-stdcall-fixup" to the linker to suppress some warnings. And I have added another linker option, namely "--kill-at" to remove the @XY decoration that MinGW normally attaches to stdcall functions. With the latter change, test_cfuncs (which had previously reported 26 failures out of 52 tests) now only reports 3. It seems that the stdcall part now passes as it does when compiled with a MSVC type compiler. Index: setup.py =================================================================== RCS file: /cvsroot/ctypes/ctypes/setup.py,v retrieving revision 1.136 retrieving revision 1.137 diff -C2 -d -r1.136 -r1.137 *** setup.py 18 Mar 2006 16:56:59 -0000 1.136 --- setup.py 27 Mar 2006 18:39:51 -0000 1.137 *************** *** 133,148 **** # is in sources, we have to add '.s'. self.compiler.src_extensions.append('.s') - # We should add the '--enable-stdcall-fixup' compiler flag for ext in self.extensions: if ext.name == "_ctypes": ext.sources.remove("source/libffi_msvc/win32.c") - # This doesn't work - the option goes to the end of the command line, - # but it should probably be at the beginning. So, we have to live - # with the warning. - ## ext.extra_compile_args.append("--enable-stdcall-fixup") else: for ext in self.extensions: if ext.name == "_ctypes": ext.sources.remove("source/libffi_msvc/win32.S") build_ext.build_ext.build_extensions(self) --- 133,144 ---- # is in sources, we have to add '.s'. self.compiler.src_extensions.append('.s') for ext in self.extensions: if ext.name == "_ctypes": ext.sources.remove("source/libffi_msvc/win32.c") else: for ext in self.extensions: if ext.name == "_ctypes": ext.sources.remove("source/libffi_msvc/win32.S") + ext.extra_link_args = [] build_ext.build_ext.build_extensions(self) *************** *** 255,260 **** --- 251,277 ---- else: extra_compile_args = [] + + # Extra arguments passed to linker from MinGW, + # will be removed, in my_build_ext, if compiler <> MinGW + extra_link_args = [] + + # In MinGW32, the first linker option should be: + # -Xlinker --enable-stdcall-fixup + # but here this option is split into two options to + # force distutils not to surroud the entire option + # with double quotes as it sees a space in it. So: + + extra_link_args.extend(["-Xlinker", "--enable-stdcall-fixup", + + # In MinGW32, the --kill-at linker option forces MinGW to + # remove the @XY decoration from function names, hence making + # the stdcall functions of _ctypes_test and those tested in + # test_cfuns.py behave similarly to the one compiled in MSVC. + + "-Wl,--kill-at"]) + extensions = [Extension("_ctypes", extra_compile_args = extra_compile_args, + extra_link_args = extra_link_args, export_symbols=["DllGetClassObject,PRIVATE", "DllCanUnloadNow,PRIVATE"], *************** *** 263,266 **** --- 280,285 ---- **kw), Extension("_ctypes_test", + extra_compile_args = extra_compile_args, + extra_link_args = extra_link_args, libraries=["oleaut32", "user32"], sources=["source/_ctypes_test.c"], |