@@ -190,6 +190,17 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
190190 fi
191191 AC_SUBST ( INCLUDE_SA )
192192
193+ # Setup default CDS alignment. On platforms where one build may run on machines with different
194+ # page sizes, the JVM choses a compatible alignment to fit all possible page sizes. This slightly
195+ # increases archive size.
196+ # The only platform having this problem at the moment is Linux on aarch64, which may encounter
197+ # three different page sizes: 4K, 64K, and if run on Mac m1 hardware, 16K.
198+ COMPATIBLE_CDS_ALIGNMENT_DEFAULT=false
199+ if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
200+ COMPATIBLE_CDS_ALIGNMENT_DEFAULT=true
201+ fi
202+ AC_SUBST ( COMPATIBLE_CDS_ALIGNMENT_DEFAULT )
203+
193204 # Compress jars
194205 COMPRESS_JARS=false
195206
@@ -491,7 +502,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER],
491502[
492503 # GCC reports lots of likely false positives for stringop-truncation and format-overflow.
493504 # Silence them for now.
494- UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base"
505+ UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment "
495506 UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER"
496507 UBSAN_LDFLAGS="$UBSAN_CHECKS"
497508 UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED,
@@ -673,7 +684,7 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
673684#
674685AC_DEFUN ( [ JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT] ,
675686[
676- UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: false ,
687+ UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT ,
677688 RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT,
678689 DESC: [ enable use alternative compatible cds core region alignment] ,
679690 DEFAULT_DESC: [ disabled] ,
0 commit comments