@@ -3841,7 +3841,7 @@ msvc_common_flags(){
-std=c99) ;;
# Common flags
-fomit-frame-pointer) ;;
- -g) echo -Z7 ;;
+ -g) echo -Zi ;;
-fno-math-errno) ;;
-fno-common) ;;
-fno-signed-zeros) ;;
@@ -4150,6 +4150,37 @@ probe_cc(){
_DEPFLAGS='$(CPPFLAGS) $(CFLAGS) -showIncludes -Zs'
_cflags_speed="-O2"
_cflags_size="-O1"
+ # Need to use -Og with -Od because otherwise has link issues with
+ # "if (ARCH_...)" code. Unfortunately, this isn't quite the same as
+ # a fully debug build. If the Dead Code Elimination (DCE) compiler
+ # optimization requirement is ever removed, this can be replaced
+ # with just -Od. Note that the use of -Og results in a compiler
+ # deprecation warning.
+ # Also added -MTd to use the multithread, static, debug version of
+ # the run-time library. -MT appears to be the default otherwise.
+ # Possible TODO: revisit and potentially use -MD and -MDd for
+ # smaller binaries.
+ _cflags_noopt="-Od -Og -MTd"
+ cl_major_ver=$(cl 2>&1 | sed -n 's/.*Version \([[:digit:]]\{1,\}\)\..*/\1/p')
+
+ # Make it easier to debug release builds.
+ # See https://msdn.microsoft.com/en-us/library/dn785163.aspx for more
+ # details.
+ # It may not be necessary to add -Zo to _cflags_noopt due to the use
+ # of -Od, but because -Og is also added currently, it is best to
+ # add -Zo for now to make sure the best debugging experience is
+ # possible. If the DCE compiler optimization requirement is ever
+ # removed, the _cflags_noopt lines can be removed.
+ if [ -z "$cl_major_ver" ] || [ $cl_major_ver -ge 18 ]; then
+ _cflags_speed="${_cflags_speed} -Zo"
+ _cflags_size="${_cflags_size} -Zo"
+ _cflags_noopt="${_cflags_noopt} -Zo"
+ else
+ _cflags_speed="${_cflags_speed} -d2Zi+"
+ _cflags_size="${_cflags_size} -d2Zi+"
+ _cflags_noopt="${_cflags_noopt} -d2Zi+"
+ fi
+
if $_cc -nologo- 2>&1 | grep -q Linker; then
_ld_o='-out:$@'
else
From 558b957eb85a669899750b2e150eba7cdee8dcd9 Mon Sep 17 00:00:00 2001 From: Aaron Levinson <alevinsn@aracnet.com> Date: Thu, 13 Apr 2017 16:46:59 -0700 Subject: [PATCH] Enhanced configure to improve compiler options associated with debugging with Visual C++ (MSVC) Purpose: Enhanced configure to improve compiler options associated with debugging with Visual C++ (MSVC) Comments: -- configure: a) In msvc_common_flags() function, replaced the use of -Z7 with -Zi. Effectively, there was no point to using -Z7 anymore given than -debug is passed to the linker already (per the line "enabled debug && add_ldflags -debug" elsewhere in the file), which causes a .pdb to be generated anyway. -Z7 causes Codeview debug info to be placed in .obj files, while -Zi causes debug info to be placed in .pdb files. As a result of switching from -Z7 to -Zi, this may result in slightly faster builds with MSVC, since it is apparently slower to process Codeview debug info. b) In probe_cc() function, added _cflags_noopt declaration for MSVC. This is set to the following: "-Od -Og -MTd". See comments for more details. This is exposed when --disable-optimizations is used with configure. In addition, now adding -Zo (or -d2Zi+, depending on the compiler version) to all the different _cflags_ variables to make it easier to debug optimized builds. See changes and comments for further details. --- configure | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)