8232084: HotSpot build failed with GCC 9.2.1
authorysuenaga
Fri, 18 Oct 2019 09:57:20 +0900
changeset 58682 9f5b92d5a1b2
parent 58681 5f14a659a8cb
child 58684 2e0462f4cf4e
8232084: HotSpot build failed with GCC 9.2.1 Reviewed-by: sspitsyn, cjplummer, dholmes, iklam
src/hotspot/cpu/x86/macroAssembler_x86.hpp
src/hotspot/share/services/diagnosticArgument.cpp
src/hotspot/share/utilities/compilerWarnings.hpp
src/hotspot/share/utilities/compilerWarnings_gcc.hpp
--- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Thu Oct 17 22:41:36 2019 +0200
+++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp	Fri Oct 18 09:57:20 2019 +0900
@@ -114,7 +114,8 @@
       // short offset operators (jmp and jcc)
       char* disp = (char*) &branch[1];
       int imm8 = target - (address) &disp[1];
-      guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset at %s:%d", file, line);
+      guarantee(this->is8bit(imm8), "Short forward jump exceeds 8-bit offset at %s:%d",
+                file == NULL ? "<NULL>" : file, line);
       *disp = imm8;
     } else {
       int* disp = (int*) &branch[(op == 0x0F || op == 0xC7)? 2: 1];
--- a/src/hotspot/share/services/diagnosticArgument.cpp	Thu Oct 17 22:41:36 2019 +0200
+++ b/src/hotspot/share/services/diagnosticArgument.cpp	Fri Oct 18 09:57:20 2019 +0900
@@ -151,7 +151,13 @@
       ResourceMark rm;
 
       char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
+
+PRAGMA_DIAG_PUSH
+PRAGMA_STRINGOP_TRUNCATION_IGNORED
+      // This code can incorrectly cause a "stringop-truncation" warning with gcc
       strncpy(buf, str, len);
+PRAGMA_DIAG_POP
+
       buf[len] = '\0';
       Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
         "Boolean parsing error in command argument '%s'. Could not parse: %s.\n", _name, buf);
--- a/src/hotspot/share/utilities/compilerWarnings.hpp	Thu Oct 17 22:41:36 2019 +0200
+++ b/src/hotspot/share/utilities/compilerWarnings.hpp	Fri Oct 18 09:57:20 2019 +0900
@@ -62,4 +62,8 @@
 #define PRAGMA_FORMAT_IGNORED
 #endif
 
+#ifndef PRAGMA_STRINGOP_TRUNCATION_IGNORED
+#define PRAGMA_STRINGOP_TRUNCATION_IGNORED
+#endif
+
 #endif // SHARE_UTILITIES_COMPILERWARNINGS_HPP
--- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp	Thu Oct 17 22:41:36 2019 +0200
+++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp	Fri Oct 18 09:57:20 2019 +0900
@@ -50,6 +50,12 @@
 
 #define PRAGMA_FORMAT_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wformat")
 
+// Disable -Wstringop-truncation which is introduced in GCC 8.
+// https://gcc.gnu.org/gcc-8/changes.html
+#if !defined(__clang_major__) && (__GNUC__ >= 8)
+#define PRAGMA_STRINGOP_TRUNCATION_IGNORED PRAGMA_DISABLE_GCC_WARNING("-Wstringop-truncation")
+#endif
+
 #if defined(__clang_major__) && \
       (__clang_major__ >= 4 || \
       (__clang_major__ >= 3 && __clang_minor__ >= 1)) || \