From ce28a96c283c3110953f9bb1333e222c2d81bd22 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 5 Feb 2020 10:45:39 +0100 Subject: [PATCH] 8238281: Raise minimum gcc version needed to 5.0 Reviewed-by: erikj, dholmes, jwilhelm, mbaesken --- doc/building.html | 7 +---- doc/building.md | 10 +------ make/autoconf/flags-cflags.m4 | 3 +-- make/autoconf/flags.m4 | 4 +-- make/autoconf/toolchain.m4 | 4 +-- make/hotspot/lib/CompileJvm.gmk | 7 ++--- src/hotspot/share/memory/operator_new.cpp | 4 +-- src/hotspot/share/prims/jvm.cpp | 4 +-- .../share/utilities/compilerWarnings_gcc.hpp | 8 +----- src/hotspot/share/utilities/debug.hpp | 9 +------ .../share/utilities/globalDefinitions_gcc.hpp | 27 +++---------------- src/hotspot/share/utilities/ostream.cpp | 4 +-- 12 files changed, 21 insertions(+), 70 deletions(-) diff --git a/doc/building.html b/doc/building.html index 13ec590f007..2f59ca8775b 100644 --- a/doc/building.html +++ b/doc/building.html @@ -301,7 +301,7 @@

All compilers are expected to be able to compile to the C99 language standard, as some C99 features are used in the source code. Microsoft Visual Studio doesn't fully support C99 so in practice shared code is limited to using C99 features that it does support.

gcc

-

The minimum accepted version of gcc is 4.8. Older versions will generate a warning by configure and are unlikely to work.

+

The minimum accepted version of gcc is 5.0. Older versions will generate a warning by configure and are unlikely to work.

The JDK is currently known to be able to compile with at least version 8.3 of gcc.

In general, any version between these two should be usable.

clang

@@ -639,11 +639,6 @@ x86_64-linux-gnu-to-ppc64le-linux-gnu

You will need two copies of your toolchain, one which generates output that can run on the target system (the normal, or target, toolchain), and one that generates output that can run on the build system (the build toolchain). Note that cross-compiling is only supported for gcc at the time being. The gcc standard is to prefix cross-compiling toolchains with the target denominator. If you follow this standard, configure is likely to pick up the toolchain correctly.

The build toolchain will be autodetected just the same way the normal build/target toolchain will be autodetected when not cross-compiling. If this is not what you want, or if the autodetection fails, you can specify a devkit containing the build toolchain using --with-build-devkit to configure, or by giving BUILD_CC and BUILD_CXX arguments.

It is often helpful to locate the cross-compilation tools, headers and libraries in a separate directory, outside the normal path, and point out that directory to configure. Do this by setting the sysroot (--with-sysroot) and appending the directory when searching for cross-compilations tools (--with-toolchain-path). As a compact form, you can also use --with-devkit to point to a single directory, if it is correctly setup. (See basics.m4 for details.)

-

If you are unsure what toolchain and versions to use, these have been proved working at the time of writing:

-

Native Libraries

You will need copies of external native libraries for the target system, present on the build machine while building.

Take care not to replace the build system's version of these libraries by mistake, since that can render the build machine unusable.

diff --git a/doc/building.md b/doc/building.md index bf541a6fdd9..ca1634737be 100644 --- a/doc/building.md +++ b/doc/building.md @@ -339,7 +339,7 @@ features that it does support. ### gcc -The minimum accepted version of gcc is 4.8. Older versions will generate a warning +The minimum accepted version of gcc is 5.0. Older versions will generate a warning by `configure` and are unlikely to work. The JDK is currently known to be able to compile with at least version 8.3 of @@ -1038,14 +1038,6 @@ appending the directory when searching for cross-compilations tools to point to a single directory, if it is correctly setup. (See `basics.m4` for details.) -If you are unsure what toolchain and versions to use, these have been proved -working at the time of writing: - - * [aarch64]( -https://releases.linaro.org/archive/13.11/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.11_linux.tar.xz) - * [arm 32-bit hardware floating point]( -https://launchpad.net/linaro-toolchain-unsupported/trunk/2012.09/+download/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tar.bz2) - ### Native Libraries You will need copies of external native libraries for the *target* system, diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index c24c6bca8da..5ae56fee8ac 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -598,8 +598,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], # our toolchains are in a condition to support that. But what we loosely aim for is # C99 level. if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xxlc; then - # This raises the language level for older 4.8 gcc, while lowering it for later - # versions. clang and xlclang support the same flag. + # Explicitly set C99. clang and xlclang support the same flag. LANGSTD_CFLAGS="-std=c99" elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then # We can't turn on -std=c99 without breaking compilation of the splashscreen/png diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index dfee0f293bd..cefbd5e3c78 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ AC_DEFUN([FLAGS_SETUP_ABI_PROFILE], # --- Arm-sflt CFLAGS and ASFLAGS --- # Armv5te is required for assembler, because pld insn used in arm32 hotspot is only in v5E and above. # However, there is also a GCC bug which generates unaligned strd/ldrd instructions on armv5te: - # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445, and it was fixed only quite recently. + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445, and it was fixed in gcc 7.1. # The resulting compromise is to enable v5TE for assembler and let GCC generate code for v5T. if test "x$OPENJDK_TARGET_ABI_PROFILE" = xarm-vfp-sflt; then ARM_FLOAT_TYPE=vfp-sflt diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index 341b2d1786a..90fcf3a509f 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ TOOLCHAIN_DESCRIPTION_xlc="IBM XL C/C++" # Minimum supported versions, empty means unspecified TOOLCHAIN_MINIMUM_VERSION_clang="3.2" -TOOLCHAIN_MINIMUM_VERSION_gcc="4.8" +TOOLCHAIN_MINIMUM_VERSION_gcc="5.0" TOOLCHAIN_MINIMUM_VERSION_microsoft="16.00.30319.01" # VS2010 TOOLCHAIN_MINIMUM_VERSION_solstudio="5.13" TOOLCHAIN_MINIMUM_VERSION_xlc="" diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 1f9610c6184..6bfb43c39b7 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -82,7 +82,7 @@ DISABLED_WARNINGS_gcc := parentheses comment unknown-pragmas address \ delete-non-virtual-dtor char-subscripts array-bounds int-in-bool-context \ ignored-qualifiers missing-field-initializers implicit-fallthrough \ empty-body strict-overflow sequence-point maybe-uninitialized \ - misleading-indentation cast-function-type + misleading-indentation cast-function-type invalid-offsetof ifeq ($(call check-jvm-feature, zero), true) DISABLED_WARNINGS_gcc += return-type switch clobbered @@ -91,7 +91,8 @@ endif DISABLED_WARNINGS_clang := tautological-compare \ undefined-var-template sometimes-uninitialized unknown-pragmas \ delete-non-virtual-dtor missing-braces char-subscripts \ - ignored-qualifiers missing-field-initializers mismatched-tags + ignored-qualifiers missing-field-initializers mismatched-tags \ + invalid-offsetof DISABLED_WARNINGS_solstudio := labelnotused hidef w_novirtualdescr inlafteruse \ unknownpragma doubunder w_enumnotused w_toomanyenumnotused \ diff --git a/src/hotspot/share/memory/operator_new.cpp b/src/hotspot/share/memory/operator_new.cpp index bf4dcc558fd..84a4152b7c3 100644 --- a/src/hotspot/share/memory/operator_new.cpp +++ b/src/hotspot/share/memory/operator_new.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,9 +91,7 @@ void operator delete [](void* p) throw() { #ifdef __GNUG__ // Warning disabled for gcc 5.4 -// Warning for unknown warning disabled for gcc 4.8.5 PRAGMA_DIAG_PUSH -PRAGMA_DISABLE_GCC_WARNING("-Wpragmas") PRAGMA_DISABLE_GCC_WARNING("-Wc++14-compat") #endif // __GNUG__ diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index bfd1473eccd..ae607cf503d 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2783,7 +2783,7 @@ void jio_print(const char* s, size_t len) { if (Arguments::vfprintf_hook() != NULL) { jio_fprintf(defaultStream::output_stream(), "%.*s", (int)len, s); } else { - // Make an unused local variable to avoid warning from gcc 4.x compiler. + // Make an unused local variable to avoid warning from gcc compiler. size_t count = ::write(defaultStream::output_fd(), s, (int)len); } } diff --git a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index 4f0d8b969d9..27ea42691a8 100644 --- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,18 +27,12 @@ // Macros related to control of compiler warnings. -// Diagnostic pragmas like the ones defined below in PRAGMA_FORMAT_NONLITERAL_IGNORED -// were only introduced in GCC 4.2. Because we have no other possibility to ignore -// these warnings for older versions of GCC, we simply don't decorate our printf-style -// functions with __attribute__(format) in that case. -#if ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || (__GNUC__ > 4) #ifndef ATTRIBUTE_PRINTF #define ATTRIBUTE_PRINTF(fmt,vargs) __attribute__((format(printf, fmt, vargs))) #endif #ifndef ATTRIBUTE_SCANF #define ATTRIBUTE_SCANF(fmt,vargs) __attribute__((format(scanf, fmt, vargs))) #endif -#endif // gcc version check #define PRAGMA_DISABLE_GCC_WARNING_AUX(x) _Pragma(#x) #define PRAGMA_DISABLE_GCC_WARNING(option_string) \ diff --git a/src/hotspot/share/utilities/debug.hpp b/src/hotspot/share/utilities/debug.hpp index 65a618a66ef..6b5b0f63429 100644 --- a/src/hotspot/share/utilities/debug.hpp +++ b/src/hotspot/share/utilities/debug.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -154,15 +154,8 @@ enum VMErrorType { // 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_vm_status_error(const char* file, int line, const char* error_msg, int status, const char* detail); void report_fatal(const char* file, int line, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(3, 4); diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index e7e602c5e70..85b0c22ab22 100644 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -210,10 +210,7 @@ inline int g_isnan(double f) { return isnan(f); } #error "missing platform-specific definition here" #endif -// GCC 4.3 does not allow 0.0/0.0 to produce a NAN value -#if (__GNUC__ == 4) && (__GNUC_MINOR__ > 2) #define CAN_USE_NAN_DEFINE 1 -#endif // Checking for finiteness @@ -238,16 +235,7 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } #define FORMAT64_MODIFIER "ll" #endif // _LP64 -// HACK: gcc warns about applying offsetof() to non-POD object or calculating -// offset directly when base address is NULL. Use 16 to get around the -// warning. gcc-3.4 has an option -Wno-invalid-offsetof to suppress -// this warning. -#define offset_of(klass,field) (size_t)((intx)&(((klass*)16)->field) - 16) - -#ifdef offsetof -# undef offsetof -#endif -#define offsetof(klass,field) offset_of(klass,field) +#define offset_of(klass,field) offsetof(klass,field) #if defined(_LP64) && defined(__APPLE__) #define JLONG_FORMAT "%ld" @@ -262,15 +250,6 @@ inline int wcslen(const jchar* x) { return wcslen((const wchar_t*)x); } // Alignment // -// NOTE! The "+0" below is a workaround for a known bug in older GCC versions -// (known to fail with 4.6.0, fixed in 4.9.0). This bug affects systems such as -// RedHat/Oracle Linux 7.5, which ships with GCC 4.8.5. For more details, see -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55382 and -// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53017 -// -// GCC versions older than 4.6.4 would fail even with "+0", and needs additional -// cast to __typeof__(x) to work around the similar bug. -// -#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned((__typeof__(x))x+0))) +#define ATTRIBUTE_ALIGNED(x) __attribute__((aligned(x))) #endif // SHARE_UTILITIES_GLOBALDEFINITIONS_GCC_HPP diff --git a/src/hotspot/share/utilities/ostream.cpp b/src/hotspot/share/utilities/ostream.cpp index 7fedb7038e2..71037482f14 100644 --- a/src/hotspot/share/utilities/ostream.cpp +++ b/src/hotspot/share/utilities/ostream.cpp @@ -531,7 +531,7 @@ fileStream::fileStream(const char* file_name, const char* opentype) { void fileStream::write(const char* s, size_t len) { if (_file != NULL) { - // Make an unused local variable to avoid warning from gcc 4.x compiler. + // Make an unused local variable to avoid warning from gcc compiler. size_t count = fwrite(s, 1, len, _file); } update_position(s, len); @@ -570,7 +570,7 @@ void fileStream::flush() { void fdStream::write(const char* s, size_t len) { if (_fd != -1) { - // Make an unused local variable to avoid warning from gcc 4.x compiler. + // Make an unused local variable to avoid warning from gcc compiler. size_t count = ::write(_fd, s, (int)len); } update_position(s, len);