Skip to content

Commit 0651f9d

Browse files
committed
Enable GCC16 compilation
1 parent 3cb2ddb commit 0651f9d

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

common/autoconf/flags.m4

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,20 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
435435
$2CXXFLAGS_JDK="${$2CXXFLAGS_JDK} ${$2CXXSTD_CXXFLAG}"
436436
$2JVM_CFLAGS="${$2JVM_CFLAGS} ${$2CXXSTD_CXXFLAG}"
437437
438+
AC_MSG_CHECKING([if the default C dialect is pre-C23])
439+
AC_LANG_PUSH([C])
440+
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[typedef int bool;]])],
441+
[AC_MSG_RESULT([yes])
442+
$2CSTD_CFLAG=""],
443+
[AC_MSG_RESULT([no, pinning -std=gnu17])
444+
$2CSTD_CFLAG="-std=gnu17"])
445+
AC_LANG_POP([C])
446+
$2CFLAGS_JDK="${$2CFLAGS_JDK} ${$2CSTD_CFLAG}"
447+
m4_if([$2], [], [
448+
LEGACY_HOST_CFLAGS="$LEGACY_HOST_CFLAGS ${CSTD_CFLAG}"
449+
LEGACY_TARGET_CFLAGS="$LEGACY_TARGET_CFLAGS ${CSTD_CFLAG}"
450+
])
451+
438452
AC_SUBST($2CXXSTD_CXXFLAG)
439453
fi
440454

common/autoconf/generated-configure.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42873,6 +42873,40 @@ $as_echo "$supports" >&6; }
4287342873
CXXFLAGS_JDK="${CXXFLAGS_JDK} ${CXXSTD_CXXFLAG}"
4287442874
JVM_CFLAGS="${JVM_CFLAGS} ${CXXSTD_CXXFLAG}"
4287542875

42876+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the default C dialect is pre-C23" >&5
42877+
$as_echo_n "checking if the default C dialect is pre-C23... " >&6; }
42878+
ac_ext=c
42879+
ac_cpp='$CPP $CPPFLAGS'
42880+
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
42881+
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
42882+
ac_compiler_gnu=$ac_cv_c_compiler_gnu
42883+
42884+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
42885+
/* end confdefs.h. */
42886+
typedef int bool;
42887+
_ACEOF
42888+
if ac_fn_c_try_compile "$LINENO"; then :
42889+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
42890+
$as_echo "yes" >&6; }
42891+
CSTD_CFLAG=""
42892+
else
42893+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, pinning -std=gnu17" >&5
42894+
$as_echo "no, pinning -std=gnu17" >&6; }
42895+
CSTD_CFLAG="-std=gnu17"
42896+
fi
42897+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
42898+
ac_ext=cpp
42899+
ac_cpp='$CXXCPP $CPPFLAGS'
42900+
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
42901+
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
42902+
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
42903+
42904+
CFLAGS_JDK="${CFLAGS_JDK} ${CSTD_CFLAG}"
42905+
42906+
LEGACY_HOST_CFLAGS="$LEGACY_HOST_CFLAGS ${CSTD_CFLAG}"
42907+
LEGACY_TARGET_CFLAGS="$LEGACY_TARGET_CFLAGS ${CSTD_CFLAG}"
42908+
42909+
4287642910

4287742911
fi
4287842912

hotspot/make/linux/makefiles/gcc.make

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ ifeq ($(USE_CLANG),)
229229
WARNINGS_ARE_ERRORS += -Wno-c++11-compat -Wno-switch -Wno-delete-non-virtual-dtor -Wno-uninitialized
230230
WARNINGS_ARE_ERRORS += -Wno-misleading-indentation -Wno-address
231231
endif
232+
ifeq "$(shell expr \( $(CC_VER_MAJOR) \>= 16 \))" "1"
233+
WARNINGS_ARE_ERRORS += -Wno-array-bounds -Wno-dangling-pointer -Wno-c++20-compat
234+
ifeq ($(BUILDARCH), aarch64)
235+
WARNINGS_ARE_ERRORS += -Wno-stringop-overflow
236+
endif
237+
endif
232238

233239
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
234240
# conversions which might affect the values. Only enable it in earlier versions.

0 commit comments

Comments
 (0)