From 3fd772e52dc6c4efd97ceefb8f277dbd21ebc825 Mon Sep 17 00:00:00 2001 From: Michael Kleehammer Date: Sat, 8 Feb 2020 11:38:34 -0600 Subject: [PATCH] Make Windows builds backwards compatible (#663) Visual Studio 2019 included new C++ exception frame handling to reduce memory, but they put it into a *new* DLL, so if you built with it you needed new DLLs installed. Turn this off. I checked Python 3.8 and it is built without it also. Eventually we'll have to turn the new flags off when a version of Python is built with it. Closes #663 --- setup.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/setup.py b/setup.py index e5ffb1ae..b205385c 100755 --- a/setup.py +++ b/setup.py @@ -159,6 +159,17 @@ def get_compiler_settings(version_str): sys.argv.remove('--windbg') settings['extra_compile_args'].extend('/Od /Ge /GS /GZ /RTC1 /Wp64 /Yd'.split()) + # Visual Studio 2019 defaults to using __CxxFrameHandler4 which is in + # VCRUNTIME140_1.DLL which Python 3.7 and earlier are not linked to. This requirement + # means pyodbc will not load unless the user has installed a UCRT update. Turn this + # off to match the Python 3.7 settings. + # + # Unfortunately these are *hidden* settings. I guess we should be glad they actually + # made the settings. + # https://lectem.github.io/msvc/reverse-engineering/build/2019/01/21/MSVC-hidden-flags.html + settings['extra_compile_args'].append('/d2FH4-') + settings['extra_link_args'].append('/d2:-FH4-') + settings['libraries'].append('odbc32') settings['libraries'].append('advapi32')