changeset 2582:000df05fbd54

PR1095: Add configure option for -Werror 2012-08-16 Andrew John Hughes <gnu_andrew@member.fsf.org> * Makefile.am: (ICEDTEA_PATCHES): Add -Werror patches from IcedTea7 HEAD. Drop ecj-opts patch as replaced by change to javac.in. (WERROR_STATUS): Set to true or false depending on if ENABLE_WERROR is set or not. (ICEDTEA_ENV): Use WERROR_STATUS to set JAVAC_WARNINGS_FATAL & COMPILER_WARNINGS_FATAL. * acinclude.m4: (IT_ENABLE_WERROR): New macro to enable -Werror. This is disabled by default. * configure.ac: Call IT_ENABLE_WERROR. * javac.in: Handle stripping of arguments which take parameters, specifically -Xmaxwarns. * patches/werror-hotspot.patch: Allow COMPILER_WARNINGS_FATAL to turn off -Werror. * patches/werror-jdk.patch: Remove cases where -Werror is forced on, allowing JAVAC_WARNINGS_FATAL and COMPILER_WARNINGS_FATAL to work correctly throughout. * patches/werror-langtools.patch: Allow JAVAC_WARNINGS_FATAL=false to turn off -Werror. * NEWS: Updated.
author Andrew John Hughes <gnu_andrew@member.fsf.org>
date Wed, 22 Aug 2012 21:21:57 +0100
parents 60bd733bd20c
children 9f42ba0226e1
files ChangeLog Makefile.am NEWS acinclude.m4 configure.ac javac.in patches/werror-hotspot.patch patches/werror-jdk.patch patches/werror-langtools.patch
diffstat 9 files changed, 234 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Aug 16 01:07:29 2012 +0100
+++ b/ChangeLog	Wed Aug 22 21:21:57 2012 +0100
@@ -1,3 +1,29 @@
+2012-08-16  Andrew John Hughes  <gnu_andrew@member.fsf.org>
+
+	* Makefile.am:
+	(ICEDTEA_PATCHES): Add -Werror patches
+	from IcedTea7 HEAD.  Drop ecj-opts patch
+	as replaced by change to javac.in.
+	(WERROR_STATUS): Set to true or false
+	depending on if ENABLE_WERROR is set or not.
+	(ICEDTEA_ENV): Use WERROR_STATUS to set
+	JAVAC_WARNINGS_FATAL & COMPILER_WARNINGS_FATAL.
+	* acinclude.m4:
+	(IT_ENABLE_WERROR): New macro to enable -Werror.
+	This is disabled by default.
+	* configure.ac: Call IT_ENABLE_WERROR.
+	* javac.in: Handle stripping of arguments which
+	take parameters, specifically -Xmaxwarns.
+	* patches/werror-hotspot.patch:
+	Allow COMPILER_WARNINGS_FATAL to turn off -Werror.
+	* patches/werror-jdk.patch:
+	Remove cases where -Werror is forced on, allowing
+	JAVAC_WARNINGS_FATAL and COMPILER_WARNINGS_FATAL
+	to work correctly throughout.
+	* patches/werror-langtools.patch:
+	Allow JAVAC_WARNINGS_FATAL=false to turn off -Werror.
+	* NEWS: Updated.
+
 2012-08-16  Andrew John Hughes  <gnu_andrew@member.fsf.org>
 
 	* Makefile.am:
--- a/Makefile.am	Thu Aug 16 01:07:29 2012 +0100
+++ b/Makefile.am	Wed Aug 22 21:21:57 2012 +0100
@@ -240,7 +240,10 @@
 
 # Patch list
 
-ICEDTEA_PATCHES =
+ICEDTEA_PATCHES = \
+	patches/werror-jdk.patch \
+	patches/werror-langtools.patch \
+	patches/werror-hotspot.patch
 
 # Conditional patches
 
@@ -311,7 +314,6 @@
 	patches/boot/corba-orb.patch \
 	patches/boot/demos.patch \
 	patches/boot/ecj-fphexconstants.patch \
-	patches/boot/ecj-opts.patch \
 	patches/boot/fontconfig.patch \
 	patches/boot/generated-comments.patch \
 	patches/boot/xbootclasspath.patch \
@@ -415,6 +417,12 @@
 ICEDTEA_PKG = $(EMPTY) (${PKGVERSION})
 endif
 
+if ENABLE_WERROR
+WERROR_STATUS=true
+else
+WERROR_STATUS=false
+endif
+
 ICEDTEA_ENV = \
 	ALT_JDK_IMPORT_PATH="$(BOOT_DIR)" \
 	ANT="$(ANT)" \
@@ -464,7 +472,9 @@
 	USE_SYSTEM_CUPS="true" \
 	CUPS_LIBS="${CUPS_LIBS}" \
 	CUPS_CFLAGS="${CUPS_CFLAGS}" \
-	STRIP_POLICY=no_strip
+	STRIP_POLICY=no_strip \
+	JAVAC_WARNINGS_FATAL="$(WERROR_STATUS)" \
+	COMPILER_WARNINGS_FATAL="$(WERROR_STATUS)"
 
 if ENABLE_CACAO
 ICEDTEA_ENV += \
--- a/NEWS	Thu Aug 16 01:07:29 2012 +0100
+++ b/NEWS	Wed Aug 22 21:21:57 2012 +0100
@@ -18,6 +18,7 @@
   - PR1050: Stream objects not garbage collected
   - PR1119: Only add classes to rt-source-files.txt if the class (or one or more of its methods/fields)
     are actually missing from the boot JDK
+  - PR1095: Add configure option for -Werror
 * JamVM
   - ARMv6 armhf: Changes for Raspbian (Raspberry Pi)
   - PPC: Don't use lwsync if it isn't supported
--- a/acinclude.m4	Thu Aug 16 01:07:29 2012 +0100
+++ b/acinclude.m4	Wed Aug 22 21:21:57 2012 +0100
@@ -2356,3 +2356,25 @@
 AM_CONDITIONAL([LACKS_$1], test x"${it_cv_$1}" = "xyes")
 AC_PROVIDE([$0])dnl
 ])
+
+AC_DEFUN([IT_ENABLE_WERROR],
+[
+  AC_MSG_CHECKING([whether to enable -Werror])
+  AC_ARG_ENABLE([Werror],
+                [AS_HELP_STRING(--enable-Werror,build with -Werror [[default=no]])],
+  [
+    case "${enableval}" in
+      yes)
+        enable_werror=yes
+        ;;
+      *)
+        enable_werror=no
+        ;;
+    esac
+  ],
+  [
+    enable_werror=no
+  ])
+  AC_MSG_RESULT([$enable_werror])
+  AM_CONDITIONAL([ENABLE_WERROR], test x"${enable_werror}" = "xyes")
+])
--- a/configure.ac	Thu Aug 16 01:07:29 2012 +0100
+++ b/configure.ac	Wed Aug 22 21:21:57 2012 +0100
@@ -152,6 +152,7 @@
 IT_WITH_JAMVM_SRC_ZIP
 
 IT_DISABLE_OPTIMIZATIONS
+IT_ENABLE_WERROR
 IT_SET_SHARK_BUILD
 IT_ENABLE_ZERO_BUILD
 IT_CHECK_ADDITIONAL_VMS
--- a/javac.in	Thu Aug 16 01:07:29 2012 +0100
+++ b/javac.in	Wed Aug 22 21:21:57 2012 +0100
@@ -1,7 +1,8 @@
 #!/usr/bin/perl -w
 use strict;
 use constant NO_DUP_ARGS => qw(-source -target -d -encoding);
-use constant STRIP_ARGS => qw(-Werror -implicit:none);
+use constant STRIP_ARGS_1 => qw(-Werror -implicit:none);
+use constant STRIP_ARGS_2 => qw(-Xmaxwarns);
 
 my ($ECJ_WARNINGS, $JAVAC_WARNINGS);
 
@@ -38,12 +39,18 @@
 	}
     }
 
-    for my $opt (STRIP_ARGS) 
+    for my $opt (STRIP_ARGS_1) 
     {
 	my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
 	splice @new_args, $_, 1 for @indices;
     }
 
+    for my $opt (STRIP_ARGS_2) 
+    {
+	my @indices = reverse grep {$new_args[$_] eq $opt} 0..$#new_args;
+	splice @new_args, $_, 2 for @indices;
+    }
+
     return @new_args;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/werror-hotspot.patch	Wed Aug 22 21:21:57 2012 +0100
@@ -0,0 +1,56 @@
+diff --git a/make/linux/makefiles/adlc.make b/make/linux/makefiles/adlc.make
+--- openjdk/hotspot/make/linux/makefiles/adlc.make
++++ openjdk/hotspot/make/linux/makefiles/adlc.make
+@@ -68,7 +68,9 @@
+ 
+ # CFLAGS_WARN holds compiler options to suppress/enable warnings.
+ # Compiler warnings are treated as errors
++ifneq ($(COMPILER_WARNINGS_FATAL),false)
+ CFLAGS_WARN = -Werror
++endif
+ CFLAGS += $(CFLAGS_WARN)
+ 
+ OBJECTNAMES = \
+diff --git a/make/linux/makefiles/gcc.make b/make/linux/makefiles/gcc.make
+--- openjdk/hotspot/make/linux/makefiles/gcc.make
++++ openjdk/hotspot/make/linux/makefiles/gcc.make
+@@ -150,7 +150,9 @@
+ endif
+ 
+ # Compiler warnings are treated as errors
++ifneq ($(COMPILER_WARNINGS_FATAL),false)
+ WARNINGS_ARE_ERRORS = -Werror
++endif
+ 
+ # Except for a few acceptable ones
+ # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
+diff --git a/make/solaris/makefiles/adlc.make b/make/solaris/makefiles/adlc.make
+--- openjdk/hotspot/make/solaris/makefiles/adlc.make
++++ openjdk/hotspot/make/solaris/makefiles/adlc.make
+@@ -75,8 +75,10 @@
+ 
+ # CFLAGS_WARN holds compiler options to suppress/enable warnings.
+ # Compiler warnings are treated as errors
+-ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
+-  CFLAGS_WARN = +w -errwarn
++ifneq ($(COMPILER_WARNINGS_FATAL),false)
++  ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1)
++    CFLAGS_WARN = +w -errwarn
++  endif
+ endif
+ CFLAGS += $(CFLAGS_WARN)
+ 
+diff --git a/make/solaris/makefiles/gcc.make b/make/solaris/makefiles/gcc.make
+--- openjdk/hotspot/make/solaris/makefiles/gcc.make
++++ openjdk/hotspot/make/solaris/makefiles/gcc.make
+@@ -112,7 +112,9 @@
+ 
+ 
+ # Compiler warnings are treated as errors 
+-WARNINGS_ARE_ERRORS = -Werror 
++ifneq ($(COMPILER_WARNINGS_FATAL),false)
++WARNINGS_ARE_ERRORS = -Werror
++endif
+ # Enable these warnings. See 'info gcc' about details on these options
+ ADDITIONAL_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare 
+ CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ADDITIONAL_WARNINGS) 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/werror-jdk.patch	Wed Aug 22 21:21:57 2012 +0100
@@ -0,0 +1,78 @@
+diff --git a/make/com/sun/nio/sctp/Makefile b/make/com/sun/nio/sctp/Makefile
+--- openjdk/jdk/make/com/sun/nio/sctp/Makefile
++++ openjdk/jdk/make/com/sun/nio/sctp/Makefile
+@@ -60,7 +60,6 @@
+   -I$(CLASSHDRDIR)/../../../../java/java.nio/nio/CClassHeaders
+ 
+ ifeq ($(PLATFORM), linux)
+-COMPILER_WARNINGS_FATAL=true
+ #OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -ljava -lnet -lpthread -ldl
+ OTHER_LDLIBS += -L$(LIBDIR)/$(LIBARCH) -lnio -lnet -lpthread -ldl
+ endif
+diff --git a/make/java/nio/Makefile b/make/java/nio/Makefile
+--- openjdk/jdk/make/java/nio/Makefile
++++ openjdk/jdk/make/java/nio/Makefile
+@@ -31,7 +31,7 @@
+ PACKAGE = java.nio
+ LIBRARY = nio
+ PRODUCT = java
+-OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint:serial -Werror
++OTHER_JAVACFLAGS += -Xmaxwarns 1000 -Xlint:serial
+ include $(BUILDDIR)/common/Defs.gmk
+ 
+ NIO_SRC = $(SHARE_SRC)/classes/java/nio
+diff --git a/make/java/sun_nio/Makefile b/make/java/sun_nio/Makefile
+--- openjdk/jdk/make/java/sun_nio/Makefile
++++ openjdk/jdk/make/java/sun_nio/Makefile
+@@ -31,7 +31,7 @@
+ PACKAGE = sun.nio
+ PRODUCT = sun
+ 
+-OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
++OTHER_JAVACFLAGS += -Xlint:serial,-deprecation
+ include $(BUILDDIR)/common/Defs.gmk
+ 
+ #
+diff --git a/make/sun/native2ascii/Makefile b/make/sun/native2ascii/Makefile
+--- openjdk/jdk/make/sun/native2ascii/Makefile
++++ openjdk/jdk/make/sun/native2ascii/Makefile
+@@ -30,7 +30,7 @@
+ BUILDDIR = ../..
+ PACKAGE = sun.tools.native2ascii
+ PRODUCT = sun
+-OTHER_JAVACFLAGS += -Xlint:serial -Werror
++OTHER_JAVACFLAGS += -Xlint:serial
+ include $(BUILDDIR)/common/Defs.gmk
+ 
+ # This program must contain a manifest that defines the execution level
+diff --git a/make/sun/nio/cs/Makefile b/make/sun/nio/cs/Makefile
+--- openjdk/jdk/make/sun/nio/cs/Makefile
++++ openjdk/jdk/make/sun/nio/cs/Makefile
+@@ -36,7 +36,7 @@
+ # This re-directs all the class files to a separate location
+ CLASSDESTDIR = $(TEMPDIR)/classes
+ 
+-OTHER_JAVACFLAGS += -Xlint:serial,-deprecation -Werror
++OTHER_JAVACFLAGS += -Xlint:serial,-deprecation
+ include $(BUILDDIR)/common/Defs.gmk
+ 
+ #
+diff --git a/make/tools/Makefile b/make/tools/Makefile
+--- openjdk/jdk/make/tools/Makefile
++++ openjdk/jdk/make/tools/Makefile
+@@ -29,7 +29,14 @@
+ 
+ BUILDDIR = ..
+ 
+-SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true JAVAC_WARNINGS_FATAL=true
++ifndef JAVAC_MAX_WARNINGS
++  SUBDIRS_MAKEFLAGS += JAVAC_MAX_WARNINGS=true
++endif
++
++ifndef JAVAC_WARNINGS_FATAL
++  SUBDIRS_MAKEFLAGS += JAVAC_WARNINGS_FATAL=true
++endif
++
+ include $(BUILDDIR)/common/Defs.gmk
+ 
+ # Note: freetypecheck is built by Sanity.gmk if needed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/werror-langtools.patch	Wed Aug 22 21:21:57 2012 +0100
@@ -0,0 +1,28 @@
+diff --git a/make/Makefile b/make/Makefile
+--- openjdk/langtools/make/Makefile
++++ openjdk/langtools/make/Makefile
+@@ -111,6 +111,12 @@
+   ANT_OPTIONS += -Ddebug.classfiles=true
+ endif
+ 
++ifeq ($(JAVAC_WARNINGS_FATAL), true)
++  ANT_OPTIONS += -Dwarnings.fatal=-Werror
++else
++  ANT_OPTIONS += -Dwarnings.fatal=
++endif
++
+ # Note: jdk/make/common/Defs.gmk uses LANGUAGE_VERSION (-source NN)
+ # and the somewhat misnamed CLASS_VERSION (-target NN)
+ ifdef TARGET_CLASS_VERSION
+diff --git a/make/build.properties b/make/build.properties
+--- openjdk/langtools/make/build.properties
++++ openjdk/langtools/make/build.properties
+@@ -68,7 +68,7 @@
+ # set the following to -version to verify the versions of javac being used
+ javac.version.opt =
+ # in time, there should be no exceptions to -Xlint:all
+-javac.lint.opts = -Xlint:all,-deprecation -Werror
++javac.lint.opts = -Xlint:all,-deprecation ${warnings.fatal}
+ 
+ # options for the <javadoc> task for javac
+ #javadoc.jls3.url=http://java.sun.com/docs/books/jls/