8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775
authorgoetz
Fri, 02 Oct 2015 11:46:42 +0200
changeset 33142 399fdb935d28
parent 33141 79da1ca44622
child 33143 2083f82acec8
8138733: Fix build: gcc < 4.8 doesn't grok -Wno-format-zero-length added in 8080775 Summary: Also fix one problematic format on ppc. Reviewed-by: david, simonis
hotspot/make/linux/makefiles/gcc.make
hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp
hotspot/src/share/vm/utilities/debug.hpp
--- a/hotspot/make/linux/makefiles/gcc.make	Thu Oct 08 01:04:29 2015 +0000
+++ b/hotspot/make/linux/makefiles/gcc.make	Fri Oct 02 11:46:42 2015 +0200
@@ -207,18 +207,22 @@
   WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
 endif
 
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual -Wno-format-zero-length
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual
 
 ifeq ($(USE_CLANG),)
   # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
   # conversions which might affect the values. Only enable it in earlier versions.
   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0"
+    # GCC < 4.3
     WARNING_FLAGS += -Wconversion
   endif  
   ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1"
+    # GCC >= 4.8
     # This flag is only known since GCC 4.3. Gcc 4.8 contains a fix so that with templates no
     # warnings are issued: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11856
     WARNING_FLAGS += -Wtype-limits
+    # GCC < 4.8 don't accept this flag for C++.
+    WARNING_FLAGS += -Wno-format-zero-length
   endif
 endif
 
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Thu Oct 08 01:04:29 2015 +0000
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Fri Oct 02 11:46:42 2015 +0200
@@ -841,7 +841,7 @@
   // Only called by MacroAssembler::verify_oop
   static void verify_oop_helper(const char* message, oop o) {
     if (!o->is_oop_or_null()) {
-      fatal(message);
+      fatal("%s", message);
     }
     ++ StubRoutines::_verify_oop_count;
   }
--- a/hotspot/src/share/vm/utilities/debug.hpp	Thu Oct 08 01:04:29 2015 +0000
+++ b/hotspot/src/share/vm/utilities/debug.hpp	Fri Oct 02 11:46:42 2015 +0200
@@ -200,8 +200,15 @@
 
 // error reporting helper functions
 void report_vm_error(const char* file, int line, const char* error_msg);
+#if !defined(__GNUC__) || defined (__clang_major__) || (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)) || __GNUC__ > 4)
+// ATTRIBUTE_PRINTF works with gcc >= 4.8 and any other compiler.
 void report_vm_error(const char* file, int line, const char* error_msg,
                      const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5);
+#else
+// GCC < 4.8 warns because of empty format string.  Warning can not be switched off selectively.
+void report_vm_error(const char* file, int line, const char* error_msg,
+                     const char* detail_fmt, ...);
+#endif
 void report_fatal(const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(3, 4);
 void report_vm_out_of_memory(const char* file, int line, size_t size, VMErrorType vm_err_type,
                              const char* detail_fmt, ...) ATTRIBUTE_PRINTF(5, 6);