1 #
   2 # Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 ###############################################################################
  27 # Terminology used in this file:
  28 #
  29 # Valid features      == All possible features that the JVM knows about.
  30 # Deprecated features == Previously known features (not considered valid).
  31 # Available features  == Features that are possible to use in this configuration.
  32 # Default features    == Features that are on by default in this configuration.
  33 # Enabled features    == Features requested by the user to be present.
  34 # Disabled features   == Features excluded from being used by the user.
  35 # Active features     == The exact set of features to be used for a JVM variant.
  36 #
  37 # All valid features are considered available, unless listed as unavailable.
  38 # All available features will be turned on as default, unless listed in a filter.
  39 ###############################################################################
  40 
  41 # We need these as m4 defines to be able to loop over them using m4 later on.
  42 
  43 # All valid JVM features, regardless of platform
  44 m4_define(jvm_features_valid, m4_normalize( \
  45     ifdef([custom_jvm_features_valid], custom_jvm_features_valid) \
  46     \
  47     aot cds compiler1 compiler2 dtrace epsilongc g1gc graal jfr jni-check \
  48     jvmci jvmti link-time-opt management minimal nmt opt-size parallelgc \
  49     serialgc services shenandoahgc static-build vm-structs zero zgc \
  50 ))
  51 
  52 # Deprecated JVM features (these are ignored, but with a warning)
  53 m4_define(jvm_features_deprecated, m4_normalize(
  54     cmsgc trace \
  55 ))
  56 
  57 # Feature descriptions
  58 m4_define(jvm_feature_desc_aot, [enable ahead of time compilation (AOT)])
  59 m4_define(jvm_feature_desc_cds, [enable class data sharing (CDS)])
  60 m4_define(jvm_feature_desc_compiler1, [enable hotspot compiler C1])
  61 m4_define(jvm_feature_desc_compiler2, [enable hotspot compiler C2])
  62 m4_define(jvm_feature_desc_dtrace, [enable dtrace support])
  63 m4_define(jvm_feature_desc_epsilongc, [include the epsilon (no-op) garbage collector])
  64 m4_define(jvm_feature_desc_g1gc, [include the G1 garbage collector])
  65 m4_define(jvm_feature_desc_graal, [enable Graal (jdk.internal.vm.compiler)])
  66 m4_define(jvm_feature_desc_jfr, [enable JDK Flight Recorder (JFR)])
  67 m4_define(jvm_feature_desc_jni_check, [enable -Xcheck:jni support])
  68 m4_define(jvm_feature_desc_jvmci, [enable JVM Compiler Interface (JVMCI)])
  69 m4_define(jvm_feature_desc_jvmti, [enable Java Virtual Machine Tool Interface (JVM TI)])
  70 m4_define(jvm_feature_desc_link_time_opt, [enable link time optimization])
  71 m4_define(jvm_feature_desc_management, [enable java.lang.management API support])
  72 m4_define(jvm_feature_desc_minimal, [support building variant 'minimal'])
  73 m4_define(jvm_feature_desc_nmt, [include native memory tracking (NMT)])
  74 m4_define(jvm_feature_desc_opt_size, [optimize the JVM library for size])
  75 m4_define(jvm_feature_desc_parallelgc, [include the parallel garbage collector])
  76 m4_define(jvm_feature_desc_serialgc, [include the serial garbage collector])
  77 m4_define(jvm_feature_desc_services, [enable diagnostic services and client attaching])
  78 m4_define(jvm_feature_desc_shenandoahgc, [include the Shenandoah garbage collector])
  79 m4_define(jvm_feature_desc_static_build, [build static library instead of dynamic])
  80 m4_define(jvm_feature_desc_vm_structs, [export JVM structures to the Serviceablility Agent])
  81 m4_define(jvm_feature_desc_zero, [support building variant 'zero'])
  82 m4_define(jvm_feature_desc_zgc, [include the Z garbage collector])
  83 
  84 ###############################################################################
  85 # Parse command line options for JVM feature selection. After this function
  86 # has run $JVM_FEATURES_ENABLED, $JVM_FEATURES_DISABLED and $JVM_FEATURES_VALID
  87 # can be used.
  88 #
  89 AC_DEFUN_ONCE([JVM_FEATURES_PARSE_OPTIONS],
  90 [
  91   # Setup shell variables from the m4 lists
  92   UTIL_SORT_LIST(JVM_FEATURES_VALID, "jvm_features_valid")
  93   UTIL_SORT_LIST(JVM_FEATURES_DEPRECATED, "jvm_features_deprecated")
  94 
  95   # For historical reasons, some jvm features have their own, shorter names.
  96   # Keep those as aliases for the --enable-jvm-feature-* style arguments.
  97   UTIL_ALIASED_ARG_ENABLE(aot, --enable-jvm-feature-aot)
  98   UTIL_ALIASED_ARG_ENABLE(cds, --enable-jvm-feature-cds)
  99   UTIL_ALIASED_ARG_ENABLE(dtrace, --enable-jvm-feature-dtrace)
 100 
 101   # First check for features using the
 102   # --with-jvm-features="<[-]feature>[,<[-]feature> ...]" syntax.
 103   AC_ARG_WITH([jvm-features], [AS_HELP_STRING([--with-jvm-features],
 104       [JVM features to enable (foo) or disable (-foo), separated by comma. Use
 105       '--help' to show possible values @<:@none@:>@])])
 106   if test "x$with_jvm_features" != x; then
 107     # Replace ","  with " ".
 108     user_jvm_feature_list=${with_jvm_features//,/ }
 109     JVM_FEATURES_ENABLED=`$ECHO $user_jvm_feature_list | \
 110         $AWK '{ for (i=1; i<=NF; i++) if (!match($i, /^-.*/)) printf("%s ", $i) }'`
 111     JVM_FEATURES_DISABLED=`$ECHO $user_jvm_feature_list | \
 112         $AWK '{ for (i=1; i<=NF; i++) if (match($i, /^-.*/)) printf("%s ", substr($i, 2))}'`
 113 
 114     # Verify that the user has provided only valid (or deprecated) features
 115     UTIL_GET_NON_MATCHING_VALUES(invalid_features, $JVM_FEATURES_ENABLED \
 116         $JVM_FEATURES_DISABLED, $JVM_FEATURES_VALID $JVM_FEATURES_DEPRECATED)
 117     if test "x$invalid_features" != x; then
 118       AC_MSG_NOTICE([Unknown JVM features specified: '$invalid_features'])
 119       AC_MSG_NOTICE([The available JVM features are: '$JVM_FEATURES_VALID'])
 120       AC_MSG_ERROR([Cannot continue])
 121     fi
 122 
 123     # Check if the user has provided deprecated features
 124     UTIL_GET_MATCHING_VALUES(deprecated_features, $JVM_FEATURES_ENABLED \
 125         $JVM_FEATURES_DISABLED, $JVM_FEATURES_DEPRECATED)
 126     if test "x$deprecated_features" != x; then
 127       AC_MSG_WARN([Deprecated JVM features specified (will be ignored): '$deprecated_features'])
 128       # Filter out deprecated features
 129       UTIL_GET_NON_MATCHING_VALUES(JVM_FEATURES_ENABLED, \
 130           $JVM_FEATURES_ENABLED, $deprecated_features)
 131       UTIL_GET_NON_MATCHING_VALUES(JVM_FEATURES_DISABLED, \
 132           $JVM_FEATURES_DISABLED, $deprecated_features)
 133     fi
 134   fi
 135 
 136   # Then check for features using the "--enable-jvm-feature-<feature>" syntax.
 137   # Using m4, loop over all features with the variable FEATURE.
 138   m4_foreach(FEATURE, m4_split(jvm_features_valid), [
 139     # Create an m4 variable containing a shell variable name (like
 140     # "enable_jvm_feature_static_build"), and the description.
 141     m4_define(FEATURE_SHELL, [enable_jvm_feature_]m4_translit(FEATURE, -, _))
 142     m4_define(FEATURE_DESCRIPTION, [jvm_feature_desc_]m4_translit(FEATURE, -, _))
 143 
 144     AC_ARG_ENABLE(jvm-feature-FEATURE, AS_HELP_STRING(
 145         [--enable-jvm-feature-FEATURE], [enable jvm feature 'FEATURE' (FEATURE_DESCRIPTION)]))
 146 
 147     if test "x$FEATURE_SHELL" = xyes; then
 148       JVM_FEATURES_ENABLED="$JVM_FEATURES_ENABLED FEATURE"
 149     elif test "x$FEATURE_SHELL" = xno; then
 150       JVM_FEATURES_DISABLED="$JVM_FEATURES_DISABLED FEATURE"
 151     elif test "x$FEATURE_SHELL" != x; then
 152       AC_MSG_ERROR([Invalid value for --enable-jvm-feature-FEATURE: '$FEATURE_SHELL'])
 153     fi
 154 
 155     m4_undefine([FEATURE_SHELL])
 156     m4_undefine([FEATURE_DESCRIPTION])
 157   ])
 158 
 159   # Likewise, check for deprecated arguments.
 160   m4_foreach(FEATURE, m4_split(jvm_features_deprecated), [
 161     AC_ARG_ENABLE(jvm-feature-FEATURE, AS_HELP_STRING(
 162         [--enable-jvm-feature-FEATURE], 
 163         [Deprecated. Option is kept for backwards compatibility and is ignored]))
 164 
 165     m4_define(FEATURE_SHELL, [enable_jvm_feature_]m4_translit(FEATURE, -, _))
 166 
 167     if test "x$FEATURE_SHELL" != x; then
 168       AC_MSG_WARN([Deprecated JVM feature, will be ignored: --enable-jvm-feature-FEATURE])
 169     fi
 170 
 171     m4_undefine([FEATURE_SHELL])
 172   ])
 173 
 174   # Check if the user has both enabled and disabled a feature
 175   UTIL_GET_MATCHING_VALUES(enabled_and_disabled, $JVM_FEATURES_ENABLED, \
 176       $JVM_FEATURES_DISABLED)
 177   if test "x$enabled_and_disabled" != x; then
 178     AC_MSG_NOTICE([These feature are both enabled and disabled: '$enabled_and_disabled'])
 179     AC_MSG_NOTICE([This can happen if you mix --with-jvm-features and --enable-jvm-feature-*])
 180     AC_MSG_NOTICE([The recommendation is to only use --enable-jvm-feature-*])
 181     AC_MSG_ERROR([Cannot continue])
 182   fi
 183 
 184   # Clean up lists and announce results to user
 185   UTIL_SORT_LIST(JVM_FEATURES_ENABLED, $JVM_FEATURES_ENABLED)
 186   AC_MSG_CHECKING([for JVM features enabled by the user])
 187   if test "x$JVM_FEATURES_ENABLED" != x; then
 188     AC_MSG_RESULT(['$JVM_FEATURES_ENABLED'])
 189   else
 190     AC_MSG_RESULT([none])
 191   fi
 192 
 193   UTIL_SORT_LIST(JVM_FEATURES_DISABLED, $JVM_FEATURES_DISABLED)
 194   AC_MSG_CHECKING([for JVM features disabled by the user])
 195   if test "x$JVM_FEATURES_DISABLED" != x; then
 196     AC_MSG_RESULT(['$JVM_FEATURES_DISABLED'])
 197   else
 198     AC_MSG_RESULT([none])
 199   fi
 200 
 201   # Makefiles use VALID_JVM_FEATURES in check-jvm-feature to verify correctness.
 202   VALID_JVM_FEATURES="$JVM_FEATURES_VALID"
 203   AC_SUBST(VALID_JVM_FEATURES)
 204 ])
 205 
 206 ###############################################################################
 207 # Helper function for the JVM_FEATURES_CHECK_* suite.
 208 # The code in the code block should assign 'false' to the variable AVAILABLE
 209 # if the feature is not available, and this function will handle everything
 210 # else that is needed.
 211 #
 212 # arg 1: The name of the feature to test
 213 # arg 2: The code block to execute
 214 #
 215 AC_DEFUN([JVM_FEATURES_CHECK_AVAILABILITY],
 216 [
 217   # Assume that feature is available
 218   AVAILABLE=true
 219 
 220   # Execute feature test block
 221   $2
 222 
 223   AC_MSG_CHECKING([if JVM feature '$1' is available])
 224   if test "x$AVAILABLE" = "xtrue"; then
 225     AC_MSG_RESULT([yes])
 226   else
 227     AC_MSG_RESULT([no])
 228     JVM_FEATURES_PLATFORM_UNAVAILABLE="$JVM_FEATURES_PLATFORM_UNAVAILABLE $1"
 229   fi
 230 ])
 231 
 232 ###############################################################################
 233 # Check if the feature 'aot' is available on this platform.
 234 #
 235 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_AOT],
 236 [
 237   JVM_FEATURES_CHECK_AVAILABILITY(aot, [
 238     AC_MSG_CHECKING([if platform is supported by AOT])
 239     # AOT is only available where JVMCI is available since it requires JVMCI.
 240     if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 241       AC_MSG_RESULT([yes])
 242     elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
 243       AC_MSG_RESULT([yes])
 244     else
 245       AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
 246       AVAILABLE=false
 247     fi
 248 
 249     AC_MSG_CHECKING([if AOT source code is present])
 250     if test -e "${TOPDIR}/src/jdk.internal.vm.compiler" && \
 251         test -e "${TOPDIR}/src/jdk.aot"; then
 252       AC_MSG_RESULT([yes])
 253     else
 254       AC_MSG_RESULT([no, missing src/jdk.internal.vm.compiler or src/jdk.aot])
 255       AVAILABLE=false
 256     fi
 257   ])
 258 ])
 259 
 260 ###############################################################################
 261 # Check if the feature 'cds' is available on this platform.
 262 #
 263 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_CDS],
 264 [
 265   JVM_FEATURES_CHECK_AVAILABILITY(cds, [
 266     AC_MSG_CHECKING([if platform is supported by CDS])
 267     if test "x$OPENJDK_TARGET_OS" != xaix; then
 268       AC_MSG_RESULT([yes])
 269     else
 270       AC_MSG_RESULT([no, $OPENJDK_TARGET_OS])
 271       AVAILABLE=false
 272     fi
 273   ])
 274 ])
 275 
 276 ###############################################################################
 277 # Check if the feature 'dtrace' is available on this platform.
 278 #
 279 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_DTRACE],
 280 [
 281   JVM_FEATURES_CHECK_AVAILABILITY(dtrace, [
 282     AC_MSG_CHECKING([for dtrace tool])
 283     if test "x$DTRACE" != "x" && test -x "$DTRACE"; then
 284       AC_MSG_RESULT([$DTRACE])
 285     else
 286       AC_MSG_RESULT([no])
 287       AVAILABLE=false
 288     fi
 289 
 290     AC_CHECK_HEADERS([sys/sdt.h], [dtrace_headers_ok=true])
 291     if test "x$dtrace_headers_ok" != "xtrue"; then
 292       HELP_MSG_MISSING_DEPENDENCY([dtrace])
 293       AC_MSG_NOTICE([Cannot enable dtrace with missing dependencies. See above.])
 294       AVAILABLE=false
 295     fi
 296   ])
 297 ])
 298 
 299 ###############################################################################
 300 # Check if the feature 'graal' is available on this platform.
 301 #
 302 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_GRAAL],
 303 [
 304   JVM_FEATURES_CHECK_AVAILABILITY(graal, [
 305     AC_MSG_CHECKING([if platform is supported by Graal])
 306     # Graal is only available where JVMCI is available since it requires JVMCI.
 307     if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 308       AC_MSG_RESULT([yes])
 309     elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
 310       AC_MSG_RESULT([yes])
 311     else
 312       AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
 313       AVAILABLE=false
 314     fi
 315   ])
 316 ])
 317 
 318 ###############################################################################
 319 # Check if the feature 'jfr' is available on this platform.
 320 #
 321 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JFR],
 322 [
 323   JVM_FEATURES_CHECK_AVAILABILITY(jfr, [
 324     AC_MSG_CHECKING([if platform is supported by JFR])
 325     if test "x$OPENJDK_TARGET_OS" = xaix; then
 326       AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
 327       AVAILABLE=false
 328     else
 329       AC_MSG_RESULT([yes])
 330     fi
 331   ])
 332 ])
 333 
 334 ###############################################################################
 335 # Check if the feature 'jvmci' is available on this platform.
 336 #
 337 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_JVMCI],
 338 [
 339   JVM_FEATURES_CHECK_AVAILABILITY(jvmci, [
 340     AC_MSG_CHECKING([if platform is supported by JVMCI])
 341     if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 342       AC_MSG_RESULT([yes])
 343     elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
 344       AC_MSG_RESULT([yes])
 345     else
 346       AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
 347       AVAILABLE=false
 348     fi
 349   ])
 350 ])
 351 
 352 ###############################################################################
 353 # Check if the feature 'shenandoahgc' is available on this platform.
 354 #
 355 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_SHENANDOAHGC],
 356 [
 357   JVM_FEATURES_CHECK_AVAILABILITY(shenandoahgc, [
 358     AC_MSG_CHECKING([if platform is supported by Shenandoah])
 359     if test "x$OPENJDK_TARGET_CPU_ARCH" = "xx86"; then
 360       AC_MSG_RESULT([yes])
 361     elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
 362       AC_MSG_RESULT([yes])
 363     else
 364       AC_MSG_RESULT([no, $OPENJDK_TARGET_CPU])
 365       AVAILABLE=false
 366     fi
 367   ])
 368 ])
 369 
 370 ###############################################################################
 371 # Check if the feature 'static-build' is available on this platform.
 372 #
 373 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_STATIC_BUILD],
 374 [
 375   JVM_FEATURES_CHECK_AVAILABILITY(static-build, [
 376     AC_MSG_CHECKING([if static-build is enabled in configure])
 377     if test "x$STATIC_BUILD" = "xtrue"; then
 378       AC_MSG_RESULT([yes])
 379     else
 380       AC_MSG_RESULT([no, use --enable-static-build to enable static build.])
 381       AVAILABLE=false
 382     fi
 383   ])
 384 ])
 385 
 386 ###############################################################################
 387 # Check if the feature 'zgc' is available on this platform.
 388 #
 389 AC_DEFUN_ONCE([JVM_FEATURES_CHECK_ZGC],
 390 [
 391   JVM_FEATURES_CHECK_AVAILABILITY(zgc, [
 392     AC_MSG_CHECKING([if platform is supported by ZGC])
 393     if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
 394       if test "x$OPENJDK_TARGET_OS" = "xlinux" || \
 395           test "x$OPENJDK_TARGET_OS" = "xwindows" || \
 396           test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
 397         AC_MSG_RESULT([yes])
 398       else
 399         AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
 400         AVAILABLE=false
 401       fi
 402     elif test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-aarch64"; then
 403       AC_MSG_RESULT([yes])
 404     else
 405       AC_MSG_RESULT([no, $OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU])
 406       AVAILABLE=false
 407     fi
 408 
 409     if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
 410       AC_MSG_CHECKING([if Windows APIs required for ZGC is present])
 411       AC_COMPILE_IFELSE(
 412         [AC_LANG_PROGRAM([[#include <windows.h>]],
 413           [[struct MEM_EXTENDED_PARAMETER x;]])
 414         ],
 415         [
 416           AC_MSG_RESULT([yes])
 417         ],
 418         [
 419           AC_MSG_RESULT([no, missing required APIs])
 420           AVAILABLE=false
 421         ]
 422       )
 423     fi
 424   ])
 425 ])
 426 
 427 ###############################################################################
 428 # Setup JVM_FEATURES_PLATFORM_UNAVAILABLE and JVM_FEATURES_PLATFORM_FILTER
 429 # to contain those features that are unavailable, or should be off by default,
 430 # for this platform, regardless of JVM variant.
 431 #
 432 AC_DEFUN_ONCE([JVM_FEATURES_PREPARE_PLATFORM],
 433 [
 434   # The checks below should add unavailable features to
 435   # JVM_FEATURES_PLATFORM_UNAVAILABLE.
 436 
 437   JVM_FEATURES_CHECK_AOT
 438   JVM_FEATURES_CHECK_CDS
 439   JVM_FEATURES_CHECK_DTRACE
 440   JVM_FEATURES_CHECK_GRAAL
 441   JVM_FEATURES_CHECK_JFR
 442   JVM_FEATURES_CHECK_JVMCI
 443   JVM_FEATURES_CHECK_SHENANDOAHGC
 444   JVM_FEATURES_CHECK_STATIC_BUILD
 445   JVM_FEATURES_CHECK_ZGC
 446 
 447   # Filter out features by default for all variants on certain platforms.
 448   # Make sure to just add to JVM_FEATURES_PLATFORM_FILTER, since it could
 449   # have a value already from custom extensions.
 450   if test "x$OPENJDK_TARGET_OS" = xaix; then
 451     JVM_FEATURES_PLATFORM_FILTER="$JVM_FEATURES_PLATFORM_FILTER jfr"
 452   fi
 453 ])
 454 
 455 ###############################################################################
 456 # Setup JVM_FEATURES_VARIANT_UNAVAILABLE and JVM_FEATURES_VARIANT_FILTER
 457 # to contain those features that are unavailable, or should be off by default,
 458 # for this particular JVM variant.
 459 #
 460 # arg 1: JVM variant
 461 #
 462 AC_DEFUN([JVM_FEATURES_PREPARE_VARIANT],
 463 [
 464   variant=$1
 465 
 466   # Check which features are unavailable for this JVM variant.
 467   # This means that is not possible to build these features for this variant.
 468   if test "x$variant" = "xminimal"; then
 469     JVM_FEATURES_VARIANT_UNAVAILABLE="cds zero"
 470   elif test "x$variant" = "xcore"; then
 471     JVM_FEATURES_VARIANT_UNAVAILABLE="cds minimal zero"
 472   elif test "x$variant" = "xzero"; then
 473     JVM_FEATURES_VARIANT_UNAVAILABLE="aot cds compiler1 compiler2 \
 474         epsilongc g1gc graal jvmci minimal shenandoahgc zgc"
 475   else
 476     JVM_FEATURES_VARIANT_UNAVAILABLE="minimal zero"
 477   fi
 478 
 479   # Check which features should be off by default for this JVM variant.
 480   if test "x$variant" = "xclient"; then
 481     JVM_FEATURES_VARIANT_FILTER="aot compiler2 graal jvmci link-time-opt opt-size"
 482   elif test "x$variant" = "xminimal"; then
 483     JVM_FEATURES_VARIANT_FILTER="aot cds compiler2 dtrace epsilongc g1gc \
 484         graal jfr jni-check jvmci jvmti management nmt parallelgc services \
 485         shenandoahgc vm-structs zgc"
 486     if test "x$OPENJDK_TARGET_CPU" = xarm ; then
 487       JVM_FEATURES_VARIANT_FILTER="$JVM_FEATURES_VARIANT_FILTER opt-size"
 488     else
 489       # Only arm-32 should have link-time-opt enabled as default.
 490       JVM_FEATURES_VARIANT_FILTER="$JVM_FEATURES_VARIANT_FILTER \
 491           link-time-opt"
 492     fi
 493   elif test "x$variant" = "xcore"; then
 494     JVM_FEATURES_VARIANT_FILTER="aot compiler1 compiler2 graal jvmci \
 495         link-time-opt opt-size"
 496   elif test "x$variant" = "xzero"; then
 497     JVM_FEATURES_VARIANT_FILTER="jfr link-time-opt opt-size"
 498   else
 499     JVM_FEATURES_VARIANT_FILTER="link-time-opt opt-size"
 500   fi
 501 ])
 502 
 503 ###############################################################################
 504 # Calculate the actual set of active JVM features for this JVM variant. Store
 505 # the result in JVM_FEATURES_ACTIVE.
 506 #
 507 # arg 1: JVM variant
 508 #
 509 AC_DEFUN([JVM_FEATURES_CALCULATE_ACTIVE],
 510 [
 511   variant=$1
 512 
 513   # The default is set to all valid features except those unavailable or listed
 514   # in a filter.
 515   if test "x$variant" != xcustom; then
 516     UTIL_GET_NON_MATCHING_VALUES(default_for_variant, $JVM_FEATURES_VALID, \
 517         $JVM_FEATURES_PLATFORM_UNAVAILABLE $JVM_FEATURES_VARIANT_UNAVAILABLE \
 518         $JVM_FEATURES_PLATFORM_FILTER $JVM_FEATURES_VARIANT_FILTER)
 519   else
 520     # Except for the 'custom' variant, where the default is to start with an
 521     # empty set.
 522     default_for_variant=""
 523   fi
 524 
 525   # Verify that explicitly enabled features are available
 526   UTIL_GET_MATCHING_VALUES(enabled_but_unavailable, $JVM_FEATURES_ENABLED, \
 527       $JVM_FEATURES_PLATFORM_UNAVAILABLE $JVM_FEATURES_VARIANT_UNAVAILABLE)
 528   if test "x$enabled_but_unavailable" != x; then
 529     AC_MSG_NOTICE([ERROR: Unavailable JVM features explicitly enabled for '$variant': '$enabled_but_unavailable'])
 530     AC_MSG_ERROR([Cannot continue])
 531   fi
 532 
 533   # Notify the user if their command line options has no real effect
 534   UTIL_GET_MATCHING_VALUES(enabled_but_default, $JVM_FEATURES_ENABLED, \
 535       $default_for_variant)
 536   if test "x$enabled_but_default" != x; then
 537     AC_MSG_NOTICE([Default JVM features explicitly enabled for '$variant': '$enabled_but_default'])
 538   fi
 539   UTIL_GET_MATCHING_VALUES(disabled_but_unavailable, $JVM_FEATURES_DISABLED, \
 540       $JVM_FEATURES_PLATFORM_UNAVAILABLE $JVM_FEATURES_VARIANT_UNAVAILABLE)
 541   if test "x$disabled_but_unavailable" != x; then
 542     AC_MSG_NOTICE([Unavailable JVM features explicitly disabled for '$variant': '$disabled_but_unavailable'])
 543   fi
 544 
 545   # JVM_FEATURES_ACTIVE is the set of all default features and all explicitly
 546   # enabled features, with the explicitly disabled features filtered out.
 547   UTIL_GET_NON_MATCHING_VALUES(JVM_FEATURES_ACTIVE, $default_for_variant \
 548       $JVM_FEATURES_ENABLED, $JVM_FEATURES_DISABLED)
 549 ])
 550 
 551 ###############################################################################
 552 # Helper function for JVM_FEATURES_VERIFY. Check if the specified JVM
 553 # feature is active. To be used in shell if constructs, like this:
 554 # 'if JVM_FEATURES_IS_ACTIVE(jvmti); then'
 555 #
 556 # Definition kept in one line to allow inlining in if statements.
 557 # Additional [] needed to keep m4 from mangling shell constructs.
 558 AC_DEFUN([JVM_FEATURES_IS_ACTIVE],
 559 [ [ [[ " $JVM_FEATURES_ACTIVE " =~ ' '$1' ' ]] ] ])
 560 
 561 ###############################################################################
 562 # Verify that the resulting set of features is consistent and legal.
 563 #
 564 # arg 1: JVM variant
 565 #
 566 AC_DEFUN([JVM_FEATURES_VERIFY],
 567 [
 568   variant=$1
 569 
 570   # Verify that dependencies are met for inter-feature relations.
 571   if JVM_FEATURES_IS_ACTIVE(aot) && ! JVM_FEATURES_IS_ACTIVE(graal); then
 572     AC_MSG_ERROR([Specified JVM feature 'aot' requires feature 'graal' for variant '$variant'])
 573   fi
 574 
 575   if JVM_FEATURES_IS_ACTIVE(graal) && ! JVM_FEATURES_IS_ACTIVE(jvmci); then
 576     AC_MSG_ERROR([Specified JVM feature 'graal' requires feature 'jvmci' for variant '$variant'])
 577   fi
 578 
 579   if JVM_FEATURES_IS_ACTIVE(jvmci) && ! (JVM_FEATURES_IS_ACTIVE(compiler1) || \
 580       JVM_FEATURES_IS_ACTIVE(compiler2)); then
 581     AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2' or 'compiler1' for variant '$variant'])
 582   fi
 583 
 584   if JVM_FEATURES_IS_ACTIVE(jvmti) && ! JVM_FEATURES_IS_ACTIVE(services); then
 585     AC_MSG_ERROR([Specified JVM feature 'jvmti' requires feature 'services' for variant '$variant'])
 586   fi
 587 
 588   if JVM_FEATURES_IS_ACTIVE(management) && ! JVM_FEATURES_IS_ACTIVE(nmt); then
 589     AC_MSG_ERROR([Specified JVM feature 'management' requires feature 'nmt' for variant '$variant'])
 590   fi
 591 
 592   # For backwards compatibility, disable a feature "globally" if one variant
 593   # is missing the feature.
 594   if ! JVM_FEATURES_IS_ACTIVE(aot); then
 595     ENABLE_AOT="false"
 596   fi
 597   if ! JVM_FEATURES_IS_ACTIVE(cds); then
 598     ENABLE_CDS="false"
 599   fi
 600   if ! JVM_FEATURES_IS_ACTIVE(graal); then
 601     INCLUDE_GRAAL="false"
 602   fi
 603   if ! JVM_FEATURES_IS_ACTIVE(jvmci); then
 604     INCLUDE_JVMCI="false"
 605   fi
 606 
 607   # Verify that we have at least one gc selected (i.e., feature named "*gc").
 608   if ! JVM_FEATURES_IS_ACTIVE(.*gc); then
 609       AC_MSG_NOTICE([At least one gc needed for variant '$variant'.])
 610       AC_MSG_NOTICE([Specified features: '$JVM_FEATURES_ACTIVE'])
 611       AC_MSG_ERROR([Cannot continue])
 612   fi
 613 ])
 614 
 615 ###############################################################################
 616 # Set up all JVM features for each enabled JVM variant. Requires that
 617 # JVM_FEATURES_PARSE_OPTIONS has been called.
 618 #
 619 AC_DEFUN_ONCE([JVM_FEATURES_SETUP],
 620 [
 621   # Set up variant-independent factors
 622   JVM_FEATURES_PREPARE_PLATFORM
 623 
 624   # For backwards compatibility, tentatively enable these features "globally",
 625   # and disable them in JVM_FEATURES_VERIFY if a variant is found that are
 626   # missing any of them.
 627   ENABLE_AOT="true"
 628   ENABLE_CDS="true"
 629   INCLUDE_GRAAL="true"
 630   INCLUDE_JVMCI="true"
 631 
 632   for variant in $JVM_VARIANTS; do
 633     # Figure out if any features are unavailable, or should be filtered out
 634     # by default, for this variant.
 635     # Store the result in JVM_FEATURES_VARIANT_UNAVAILABLE and
 636     # JVM_FEATURES_VARIANT_FILTER.
 637     JVM_FEATURES_PREPARE_VARIANT($variant)
 638 
 639     # Calculate the resulting set of enabled features for this variant.
 640     # The result is stored in JVM_FEATURES_ACTIVE.
 641     JVM_FEATURES_CALCULATE_ACTIVE($variant)
 642 
 643     # Verify consistency for JVM_FEATURES_ACTIVE.
 644     JVM_FEATURES_VERIFY($variant)
 645 
 646     # Keep feature list sorted and free of duplicates
 647     UTIL_SORT_LIST(JVM_FEATURES_ACTIVE, $JVM_FEATURES_ACTIVE)
 648     AC_MSG_CHECKING([JVM features to use for variant '$variant'])
 649     AC_MSG_RESULT(['$JVM_FEATURES_ACTIVE'])
 650 
 651     # Save this as e.g. JVM_FEATURES_server, using indirect variable
 652     # referencing.
 653     features_var_name=JVM_FEATURES_$variant
 654     eval $features_var_name=\"$JVM_FEATURES_ACTIVE\"
 655   done
 656 
 657   # Unfortunately AC_SUBST does not work with non-literally named variables,
 658   # so list all variants here.
 659   AC_SUBST(JVM_FEATURES_server)
 660   AC_SUBST(JVM_FEATURES_client)
 661   AC_SUBST(JVM_FEATURES_minimal)
 662   AC_SUBST(JVM_FEATURES_core)
 663   AC_SUBST(JVM_FEATURES_zero)
 664   AC_SUBST(JVM_FEATURES_custom)
 665 
 666   AC_SUBST(ENABLE_AOT)
 667   AC_SUBST(INCLUDE_GRAAL)
 668   AC_SUBST(INCLUDE_JVMCI)
 669 
 670 ])