changeset 1490:cfd05cc6c27b

8074859: Turn on warnings as error Reviewed-by: erikj
author ihse
date Fri, 08 May 2015 10:37:13 +0200
parents 82cf9aab9a83
children 59a521e95401
files common/autoconf/flags.m4 common/autoconf/generated-configure.sh common/autoconf/spec.gmk.in make/Init.gmk make/common/NativeCompilation.gmk
diffstat 5 files changed, 70 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/flags.m4	Thu May 07 20:49:31 2015 -0700
+++ b/common/autoconf/flags.m4	Fri May 08 10:37:13 2015 +0200
@@ -231,7 +231,6 @@
 
   AC_SUBST(C_FLAG_REORDER)
   AC_SUBST(CXX_FLAG_REORDER)
-  AC_SUBST(SHARED_LIBRARY_FLAGS)
   AC_SUBST(SET_EXECUTABLE_ORIGIN)
   AC_SUBST(SET_SHARED_LIBRARY_ORIGIN)
   AC_SUBST(SET_SHARED_LIBRARY_NAME)
@@ -900,6 +899,24 @@
       [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
   AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
 
+  AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
+      [do not consider native warnings to be an error @<:@enabled@:>@])])
+
+  AC_MSG_CHECKING([if native warnings are errors])
+  if test "x$enable_warnings_as_errors" = "xyes"; then
+    AC_MSG_RESULT([yes (explicitely set)])
+    WARNINGS_AS_ERRORS=true
+  elif test "x$enable_warnings_as_errors" = "xno"; then
+    AC_MSG_RESULT([no])
+    WARNINGS_AS_ERRORS=false
+  elif test "x$enable_warnings_as_errors" = "x"; then
+    AC_MSG_RESULT([yes (default)])
+    WARNINGS_AS_ERRORS=true
+  else
+    AC_MSG_ERROR([--enable-warnings-as-errors accepts no argument])
+  fi
+  AC_SUBST(WARNINGS_AS_ERRORS)
+
   case "${TOOLCHAIN_TYPE}" in
     microsoft)
       DISABLE_WARNING_PREFIX="-wd"
--- a/common/autoconf/generated-configure.sh	Thu May 07 20:49:31 2015 -0700
+++ b/common/autoconf/generated-configure.sh	Fri May 08 10:37:13 2015 +0200
@@ -684,6 +684,7 @@
 ENABLE_DEBUG_SYMBOLS
 CFLAGS_WARNINGS_ARE_ERRORS
 DISABLE_WARNING_PREFIX
+WARNINGS_AS_ERRORS
 COMPILER_SUPPORTS_TARGET_BITS_FLAG
 ZERO_ARCHFLAG
 LDFLAGS_TESTEXE_SUFFIX
@@ -727,7 +728,6 @@
 SET_SHARED_LIBRARY_NAME
 SET_SHARED_LIBRARY_ORIGIN
 SET_EXECUTABLE_ORIGIN
-SHARED_LIBRARY_FLAGS
 CXX_FLAG_REORDER
 C_FLAG_REORDER
 SYSROOT_LDFLAGS
@@ -1086,6 +1086,7 @@
 with_extra_cflags
 with_extra_cxxflags
 with_extra_ldflags
+enable_warnings_as_errors
 enable_debug_symbols
 enable_zip_debug_info
 enable_native_coverage
@@ -1852,6 +1853,9 @@
   --enable-rmiconnector-iiop
                           enable the JMX RMIConnector iiop transport
                           [disabled]
+  --disable-warnings-as-errors
+                          do not consider native warnings to be an error
+                          [enabled]
   --disable-debug-symbols disable generation of debug symbols [enabled]
   --disable-zip-debug-info
                           disable zipping of debug-info files [enabled]
@@ -4359,7 +4363,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1430918902
+DATE_WHEN_GENERATED=1431074105
 
 ###############################################################################
 #
@@ -41761,7 +41765,6 @@
 
 
 
-
   if test "x$OPENJDK_TARGET_OS" = xsolaris; then
     CFLAGS_JDK="${CFLAGS_JDK} -D__solaris__"
     CXXFLAGS_JDK="${CXXFLAGS_JDK} -D__solaris__"
@@ -42471,6 +42474,31 @@
 
 
 
+  # Check whether --enable-warnings-as-errors was given.
+if test "${enable_warnings_as_errors+set}" = set; then :
+  enableval=$enable_warnings_as_errors;
+fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if native warnings are errors" >&5
+$as_echo_n "checking if native warnings are errors... " >&6; }
+  if test "x$enable_warnings_as_errors" = "xyes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (explicitely set)" >&5
+$as_echo "yes (explicitely set)" >&6; }
+    WARNINGS_AS_ERRORS=true
+  elif test "x$enable_warnings_as_errors" = "xno"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    WARNINGS_AS_ERRORS=false
+  elif test "x$enable_warnings_as_errors" = "x"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (default)" >&5
+$as_echo "yes (default)" >&6; }
+    WARNINGS_AS_ERRORS=true
+  else
+    as_fn_error $? "--enable-warnings-as-errors accepts no argument" "$LINENO" 5
+  fi
+
+
   case "${TOOLCHAIN_TYPE}" in
     microsoft)
       DISABLE_WARNING_PREFIX="-wd"
--- a/common/autoconf/spec.gmk.in	Thu May 07 20:49:31 2015 -0700
+++ b/common/autoconf/spec.gmk.in	Fri May 08 10:37:13 2015 +0200
@@ -321,6 +321,9 @@
 DISABLE_WARNING_PREFIX := @DISABLE_WARNING_PREFIX@
 CFLAGS_WARNINGS_ARE_ERRORS:=@CFLAGS_WARNINGS_ARE_ERRORS@
 
+# A global flag (true or false) determining if native warnings are considered errors.
+WARNINGS_AS_ERRORS := @WARNINGS_AS_ERRORS@
+
 CFLAGS_CCACHE:=@CFLAGS_CCACHE@
 
 # Tools that potentially need to be cross compilation aware.
@@ -394,9 +397,6 @@
 
 LIPO:=@LIPO@
 
-# Command to create a shared library
-SHARED_LIBRARY_FLAGS:=@SHARED_LIBRARY_FLAGS@
-
 # Options to linker to specify a mapfile.
 # (Note absence of := assignment, because we do not want to evaluate the macro body here)
 SET_SHARED_LIBRARY_MAPFILE=@SET_SHARED_LIBRARY_MAPFILE@
--- a/make/Init.gmk	Thu May 07 20:49:31 2015 -0700
+++ b/make/Init.gmk	Fri May 08 10:37:13 2015 +0200
@@ -267,7 +267,9 @@
 	    ( cd $(TOPDIR) && \
 	        $(BUILD_LOG_WRAPPER) $(MAKE) $(MAKE_ARGS) $(OUTPUT_SYNC_FLAG) \
 	        -j $(JOBS) -f make/Main.gmk $(USER_MAKE_VARS) \
-	        $(PARALLEL_TARGETS) )
+	        $(PARALLEL_TARGETS) || \
+	        ( exitcode=$$? && $(BUILD_LOG_WRAPPER) $(PRINTF) "\nERROR: Build failed for $(TARGET_DESCRIPTION) (exit code $$exitcode) \n" && \
+	        $(PRINTF) "Hint: If caused by a warning, try configure --disable-warnings-as-errors \n\n" && exit $$exitcode ) )
 	    $(call CleanupSmartJavac)
 	    $(call StopGlobalTimer)
 	    $(call ReportBuildTimes)
--- a/make/common/NativeCompilation.gmk	Thu May 07 20:49:31 2015 -0700
+++ b/make/common/NativeCompilation.gmk	Fri May 08 10:37:13 2015 +0200
@@ -487,6 +487,21 @@
     $1_EXTRA_CXXFLAGS += $$(addprefix $(DISABLE_WARNING_PREFIX), $$($1_DISABLED_WARNINGS_$(TOOLCHAIN_TYPE)))
   endif
 
+  # Check if warnings should be considered errors.
+  # Pick first binary and toolchain specific, then binary specific, then general setting.
+  ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)),)
+    ifeq ($$($1_WARNINGS_AS_ERRORS),)
+      $1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$(WARNINGS_AS_ERRORS)
+    else
+      $1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE) := $$($1_WARNINGS_AS_ERRORS)
+    endif
+  endif
+
+  ifeq ($$($1_WARNINGS_AS_ERRORS_$(TOOLCHAIN_TYPE)), true)
+    $1_EXTRA_CFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
+    $1_EXTRA_CXXFLAGS += $(CFLAGS_WARNINGS_ARE_ERRORS)
+  endif
+
   ifeq (NONE, $$($1_OPTIMIZATION))
     $1_EXTRA_CFLAGS += $(C_O_FLAG_NONE)
     $1_EXTRA_CXXFLAGS += $(CXX_O_FLAG_NONE)