6991482: Add global jdk makefile options to silence some VS2010 warnings
authorohair
Tue, 28 Dec 2010 16:12:31 -0800
changeset 7669 3ebe17bda998
parent 7668 d4a77089c587
child 7670 239a99709040
6991482: Add global jdk makefile options to silence some VS2010 warnings Reviewed-by: prr
jdk/make/common/Defs-windows.gmk
jdk/make/common/shared/Defs-windows.gmk
jdk/make/common/shared/Sanity-Settings.gmk
--- a/jdk/make/common/Defs-windows.gmk	Tue Dec 28 15:53:50 2010 -0800
+++ b/jdk/make/common/Defs-windows.gmk	Tue Dec 28 16:12:31 2010 -0800
@@ -294,6 +294,13 @@
 
 # Always add _STATIC_CPPLIB definition
 STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB
+
+# Silence the warning about using _STATIC_CPPLIB
+ifneq ($(SHOW_ALL_WARNINGS),true)
+  # Needed with VS2010 to turn off the deprecated warning.
+  STATIC_CPPLIB_OPTION += /D _DISABLE_DEPRECATE_STATIC_CPPLIB
+endif
+
 MS_RUNTIME_OPTION += $(STATIC_CPPLIB_OPTION)
 
 ifeq ($(CC_VERSION),msvc)
@@ -305,7 +312,7 @@
   #   -Od      Turns off optimization and speeds compilation
   #   -YX -Fp/.../foobar.pch   Use precompiled headers (try someday?)
   #   -nologo  Don't print out startup message
-  #   /D _STATIC_CPPLIB  
+  #   /D _STATIC_CPPLIB
   #            Use static link for the C++ runtime (so msvcpnn.dll not needed)
   #   
   CFLAGS_COMMON  += -Zi -nologo
@@ -395,12 +402,20 @@
 # Treat compiler warnings as errors, if requested
 #
 CFLAGS_COMMON += -W$(COMPILER_WARNING_LEVEL)
-# Turn off security warnings about using the standard C library function strcpy
-CFLAGS_COMMON += -D _CRT_SECURE_NO_DEPRECATE
 ifeq ($(COMPILER_WARNINGS_FATAL),true)
   CFLAGS_COMMON += -WX
 endif
 
+# Turn off some warnings by default, enable them all if asked.
+ifneq ($(SHOW_ALL_WARNINGS),true)
+  # The -D _CRT_SECURE_NO_DEPRECATE turns off security/deprecated warnings on
+  #    the standard C library functions like strcpy.
+  CFLAGS_COMMON += -D _CRT_SECURE_NO_DEPRECATE
+  # The -D _CRT_NONSTDC_NO_DEPRECATE turns off deprecation warnings about using
+  #    non-standard C POSIX functions.
+  CFLAGS_COMMON += -D _CRT_NONSTDC_NO_DEPRECATE
+endif
+
 CPPFLAGS_OPT    = -DNDEBUG
 CPPFLAGS_DBG    = -DDEBUG -DLOGGING
 
--- a/jdk/make/common/shared/Defs-windows.gmk	Tue Dec 28 15:53:50 2010 -0800
+++ b/jdk/make/common/shared/Defs-windows.gmk	Tue Dec 28 16:12:31 2010 -0800
@@ -34,12 +34,17 @@
 #    Program.gmk may turn this down to 2 (building .exe's).
 #    Windows 64bit platforms are less likely to be warning free.
 #    Historically, Windows 32bit builds should be mostly warning free.
+#    VS2010 introduced a large number of security warnings that are off by
+#    default but will be turned back on with SHOW_ALL_WARNINGS=true.
 ifndef COMPILER_WARNING_LEVEL
   COMPILER_WARNING_LEVEL=3
 endif
 ifndef COMPILER_WARNINGS_FATAL
   COMPILER_WARNINGS_FATAL=false
 endif
+ifndef SHOW_ALL_WARNINGS
+  SHOW_ALL_WARNINGS = false
+endif
 
 # Windows should use parallel compilation for best build times
 ifndef COMPILE_APPROACH
--- a/jdk/make/common/shared/Sanity-Settings.gmk	Tue Dec 28 15:53:50 2010 -0800
+++ b/jdk/make/common/shared/Sanity-Settings.gmk	Tue Dec 28 16:12:31 2010 -0800
@@ -138,6 +138,7 @@
 ALL_SETTINGS+=$(call addOptionalSetting,FASTDEBUG)
 ALL_SETTINGS+=$(call addRequiredSetting,COMPILER_WARNINGS_FATAL)
 ALL_SETTINGS+=$(call addOptionalSetting,COMPILER_WARNING_LEVEL)
+ALL_SETTINGS+=$(call addOptionalSetting,SHOW_ALL_WARNINGS)
 ALL_SETTINGS+=$(call addRequiredSetting,INCREMENTAL_BUILD)
 ALL_SETTINGS+=$(call addOptionalSetting,CC_HIGHEST_OPT)
 ALL_SETTINGS+=$(call addOptionalSetting,CC_HIGHER_OPT)