diff options
author | Steven Johnson <srj@google.com> | 2017-04-24 12:16:35 +0200 |
---|---|---|
committer | Vladimir Moskva <vladmos@google.com> | 2017-04-24 16:51:41 +0200 |
commit | 0512a0e4eaa6b17b85a494eb601dddd53737f9be (patch) | |
tree | 7a6447a755cba172cc057bc2c44202d4a8ca77df /tools/cpp/wrapper/bin | |
parent | 92b14b02500fffc58a2e4c393d71913c338f362c (diff) |
MSVC: attempt to choose msvcrt.lib vs libcmt.lib correctly
See Issue #2120: if we specify /MD for copts, we should attempt to use
MSVCRTx.lib instead of LIBCMTx.lib.
Closes #2862.
PiperOrigin-RevId: 154032031
Diffstat (limited to 'tools/cpp/wrapper/bin')
-rw-r--r-- | tools/cpp/wrapper/bin/pydir/msvc_link.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/cpp/wrapper/bin/pydir/msvc_link.py b/tools/cpp/wrapper/bin/pydir/msvc_link.py index c0011a256e..79ce688cf7 100644 --- a/tools/cpp/wrapper/bin/pydir/msvc_link.py +++ b/tools/cpp/wrapper/bin/pydir/msvc_link.py @@ -114,10 +114,14 @@ class MsvcLinker(msvc_tools.WindowsRunner): raise ValueError('Must specify compilation mode ' '(-Xcompilation-mode={dbg,fastbuild,opt})') - if parser.compilation_mode == 'dbg': - default_args.insert(0, 'libcmtd.lib') - else: - default_args.insert(0, 'libcmt.lib') + rtlib = 'libcmt%s.lib' + # attempt to choose the right runtime library if we can + for opt in reversed(parser.options): + if opt in ['/MT', '/MTd']: + rtlib = 'msvcrt%s.lib' + break + default_args.insert(0, rtlib % + ('d' if parser.compilation_mode == 'dbg' else '')) return self.RunBinary(tool, default_args + parser.options, parser.target_arch, parser) |