Opened 9 years ago

Closed 6 years ago

#5972 closed enhancement (fixed)

improve msvc compile options

Reported by: Hoenir Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc: tamas

Description

Imo one should by default enable /MP to speed up compilation and always optimize the binaries for size. Also I think you should consider completely disabling exception handling by replacing /EHsc with /D_HAS_EXCEPTIONS=0 (that's needed for the STL).

An actual bugfix is to pass /MDd instead of /MD in debug mode.

For my builds I furthermore enable LTCG when building a dll and use Z7 for debug info, which works fine just like Zi for dlls and for static libraries takes a bit more space but does not require you to ship a separate pdb.

Index: nmake.opt
===================================================================
--- nmake.opt	(revision 29221)
+++ nmake.opt	(working copy)
@@ -128,9 +128,9 @@
 !IFNDEF OPTFLAGS
 !IF $(MSVC_VER) >= 1400
 !IFNDEF DEBUG
-OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MD /EHsc /Ox /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG
+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /MP /nologo /MD /D_HAS_EXCEPTIONS=0 /Z7 /O2 /GL /Gw /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DNDEBUG
 !ELSE
-OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /nologo /MD /EHsc /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG
+OPTFLAGS= $(CXX_ANALYZE_FLAGS) $(CXX_PDB_FLAGS) /MP /nologo /MDd /Z7 /D_HAS_EXCEPTIONS=0 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /DDEBUG
 !ENDIF
 !ELSE
 !IFNDEF DEBUG
@@ -163,13 +163,15 @@
 
 # Linker debug options
 !IFDEF DEBUG
-LDEBUG= /debug
+LDEBUG= /debug /incremental:no
+!ELSE
+LDEBUG= /debug /incremental:no /OPT:REF /OPT:ICF
 !ENDIF
 
 # Uncomment the following if you are building for 64-bit windows

Change History (4)

comment:1 by Even Rouault, 9 years ago

Cc: tamas added

Tamas, thoughts ? Regarding /MDd instead of /MD, I'm pretty sure there are tickets (or email discussions) about that where other people requested /MDd but /MD was still seen as preferable.

comment:2 by Hoenir, 9 years ago

Ok well at least /MDd is the default for debug configurations.

comment:3 by Jukka Rahkonen, 6 years ago

Does this ticket belong to the same group than those four listed (and closed) in #6384?

comment:4 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

Closing. Resolved per #6384

Note: See TracTickets for help on using tickets.