[Distutils] Bug report: debug builds on msvc compiler don't specify
*_d.lib as link sources
Fri Sep 29 07:29:01 2000
This is a multi-part message in MIME format.
Content-Type: text/plain; charset=us-ascii
Thomas Heller wrote:
> > In ccompiler, you have this code in gen_lib_options:
> > for lib in libraries:
> > (lib_dir, lib_name) = os.path.split (lib)
> > if lib_dir:
> > lib_file = compiler.find_library_file ([lib_dir], lib_name)
> > if lib_file:
> > lib_opts.append (lib_file)
> > else:
> > compiler.warn ("no library file corresponding to "
> > "'%s' found (skipping)" % lib)
> > else:
> > lib_opts.append (compiler.library_option (lib))
> > Note that you aren't passing "debug" to compiler.find_library_file, so the
> > debug libraries will never get used. Also note that msvccompiler doesn't
> > provide for passing the debug flag to library_option, so it doesn't do the
> > proper name mangling (adding _d) for the library name. I'm guessing
> > need to make gen_lib_options get passed the debug flag, and then make it
> > pass that flag on to the compiler methods. No clue what to do for
> > compilers (or even if they need debug flags).
BorlandCCompiler doesn't use gen_lib_options() and handles debug
correct. It uses its own find_library_file() which uses python15_d.lib
(or python15_d_bcpp.lib) if it exists.
MSVCCompiler has also its own find_library_file() method which works the
same way. The only problem is that gen_lib_option() calls it without the
I made the changes you describe above in a patch
The only problem is now, it is not tested by me because I'm currently
20 km away from my msvccompiler-distutils-test-machine.
> You are completely right: MSVCCompiler links with the wrong library
> on debug builds.
> I just tried and noticed that python15.lib is explicitely passed
> to the linker (for both debug and release builds) although this
> is completely unneccessary for MSVC, since the python import library
> is already set with in pragma in Python.h.
Explicitely passing 'python15' as library should not be problem if
gen_lib_options() works correct. (You would name a library twice
(pragma and explicit) for MSVC, but on the other side 'build_ext'
doesn't need to know about special compiler classes.)
Content-Type: text/plain; charset=us-ascii;
diff -BurN --exclude=*.pyc --minimal distutils/distutils/ccompiler.py distutils.patched/distutils/ccompiler.py
--- distutils/distutils/ccompiler.py Wed Sep 27 11:26:08 2000
+++ distutils.patched/distutils/ccompiler.py Fri Sep 29 13:11:54 2000
@@ -969,7 +969,11 @@
# gen_preprocess_options ()
-def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
+def gen_lib_options (compiler,
"""Generate linker options for searching library directories and
linking with specific libraries. 'libraries' and 'library_dirs' are,
respectively, lists of library names (not filenames!) and search
@@ -993,7 +997,7 @@
for lib in libraries:
(lib_dir, lib_name) = os.path.split (lib)
- lib_file = compiler.find_library_file ([lib_dir], lib_name)
+ lib_file = compiler.find_library_file ([lib_dir], lib_name, debug)
diff -BurN --exclude=*.pyc --minimal distutils/distutils/command/build_ext.py distutils.patched/distutils/command/build_ext.py
--- distutils/distutils/command/build_ext.py Fri Sep 29 10:24:57 2000
+++ distutils.patched/distutils/command/build_ext.py Fri Sep 29 13:16:08 2000
@@ -568,8 +568,8 @@
if sys.platform == "win32" and \
not isinstance(self.compiler, MSVCCompiler):
template = "python%d%d"
- if self.debug:
- template = template + '_d'
+ #if self.debug:
+ # template = template + '_d'
pythonlib = (template %
(sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
# don't extend ext.libraries, it may be shared with other
diff -BurN --exclude=*.pyc --minimal distutils/distutils/msvccompiler.py distutils.patched/distutils/msvccompiler.py
--- distutils/distutils/msvccompiler.py Wed Sep 27 11:26:10 2000
+++ distutils.patched/distutils/msvccompiler.py Fri Sep 29 13:12:34 2000
@@ -420,7 +420,7 @@
lib_opts = gen_lib_options (self,
+ libraries, debug)
if output_dir is not None:
output_filename = os.path.join (output_dir, output_filename)