@@ -3844,7 +3844,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) ;;
@@ -4153,6 +4153,33 @@ 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.
+ _cflags_noopt="-Od -Og"
+ 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