hotspot.m4 revision 2153:802f90289006
1160814Ssimon# 2296341Sdelphij# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3296341Sdelphij# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4296341Sdelphij# 5160814Ssimon# This code is free software; you can redistribute it and/or modify it 6160814Ssimon# under the terms of the GNU General Public License version 2 only, as 7160814Ssimon# published by the Free Software Foundation. Oracle designates this 8160814Ssimon# particular file as subject to the "Classpath" exception as provided 9160814Ssimon# by Oracle in the LICENSE file that accompanied this code. 10160814Ssimon# 11160814Ssimon# This code is distributed in the hope that it will be useful, but WITHOUT 12160814Ssimon# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13160814Ssimon# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14296341Sdelphij# version 2 for more details (a copy is included in the LICENSE file that 15160814Ssimon# accompanied this code). 16160814Ssimon# 17160814Ssimon# You should have received a copy of the GNU General Public License version 18160814Ssimon# 2 along with this work; if not, write to the Free Software Foundation, 19160814Ssimon# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20160814Ssimon# 21160814Ssimon# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22160814Ssimon# or visit www.oracle.com if you need additional information or have any 23160814Ssimon# questions. 24160814Ssimon# 25160814Ssimon 26160814Ssimon# All valid JVM features, regardless of platform 27160814SsimonVALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \ 28160814Ssimon fprof vm-structs jni-check services management all-gcs nmt cds static-build" 29160814Ssimon 30160814Ssimon# All valid JVM variants 31160814SsimonVALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" 32160814Ssimon 33160814Ssimon############################################################################### 34160814Ssimon# Check if the specified JVM variant should be built. To be used in shell if 35160814Ssimon# constructs, like this: 36160814Ssimon# if HOTSPOT_CHECK_JVM_VARIANT(server); then 37160814Ssimon# 38160814Ssimon# Only valid to use after HOTSPOT_SETUP_JVM_VARIANTS has setup variants. 39160814Ssimon 40160814Ssimon# Definition kept in one line to allow inlining in if statements. 41160814Ssimon# Additional [] needed to keep m4 from mangling shell constructs. 42160814SsimonAC_DEFUN([HOTSPOT_CHECK_JVM_VARIANT], 43160814Ssimon[ [ [[ " $JVM_VARIANTS " =~ " $1 " ]] ] ]) 44160814Ssimon 45160814Ssimon############################################################################### 46160814Ssimon# Check if the specified JVM features are explicitly enabled. To be used in 47160814Ssimon# shell if constructs, like this: 48160814Ssimon# if HOTSPOT_CHECK_JVM_FEATURE(jvmti); then 49160814Ssimon# 50160814Ssimon# Only valid to use after HOTSPOT_SETUP_JVM_FEATURES has setup features. 51160814Ssimon 52160814Ssimon# Definition kept in one line to allow inlining in if statements. 53160814Ssimon# Additional [] needed to keep m4 from mangling shell constructs. 54160814SsimonAC_DEFUN([HOTSPOT_CHECK_JVM_FEATURE], 55160814Ssimon[ [ [[ " $JVM_FEATURES " =~ " $1 " ]] ] ]) 56160814Ssimon 57160814Ssimon############################################################################### 58160814Ssimon# Check which variants of the JVM that we want to build. Available variants are: 59160814Ssimon# server: normal interpreter, and a tiered C1/C2 compiler 60160814Ssimon# client: normal interpreter, and C1 (no C2 compiler) 61160814Ssimon# minimal: reduced form of client with optional features stripped out 62160814Ssimon# core: normal interpreter only, no compiler 63160814Ssimon# zero: C++ based interpreter only, no compiler 64160814Ssimon# zeroshark: C++ based interpreter, and a llvm-based compiler 65160814Ssimon# custom: baseline JVM with no default features 66160814Ssimon# 67160814SsimonAC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS], 68160814Ssimon[ 69160814Ssimon AC_ARG_WITH([jvm-variants], [AS_HELP_STRING([--with-jvm-variants], 70160814Ssimon [JVM variants (separated by commas) to build (server,client,minimal,core,zero,zeroshark,custom) @<:@server@:>@])]) 71160814Ssimon 72296341Sdelphij if test "x$with_jvm_variants" = x; then 73296341Sdelphij with_jvm_variants="server" 74296341Sdelphij fi 75296341Sdelphij JVM_VARIANTS_OPT="$with_jvm_variants" 76296341Sdelphij 77296341Sdelphij # Has the user listed more than one variant? 78296341Sdelphij # Additional [] needed to keep m4 from mangling shell constructs. 79296341Sdelphij if [ [[ "$JVM_VARIANTS_OPT" =~ "," ]] ]; then 80296341Sdelphij BUILDING_MULTIPLE_JVM_VARIANTS=true 81296341Sdelphij else 82296341Sdelphij BUILDING_MULTIPLE_JVM_VARIANTS=false 83296341Sdelphij fi 84296341Sdelphij # Replace the commas with AND for use in the build directory name. 85296341Sdelphij JVM_VARIANTS_WITH_AND=`$ECHO "$JVM_VARIANTS_OPT" | $SED -e 's/,/AND/g'` 86296341Sdelphij 87296341Sdelphij AC_MSG_CHECKING([which variants of the JVM to build]) 88296341Sdelphij # JVM_VARIANTS is a space-separated list. 89160814Ssimon # Also use minimal, not minimal1 (which is kept for backwards compatibility). 90160814Ssimon JVM_VARIANTS=`$ECHO $JVM_VARIANTS_OPT | $SED -e 's/,/ /g' -e 's/minimal1/minimal/'` 91296341Sdelphij AC_MSG_RESULT([$JVM_VARIANTS]) 92296341Sdelphij 93296341Sdelphij # Check that the selected variants are valid 94296341Sdelphij 95296341Sdelphij # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326 96296341Sdelphij # Notice that the original variant failes on SLES 10 and 11 97296341Sdelphij NEEDLE=${VALID_JVM_VARIANTS// /$'\n'} 98296341Sdelphij STACK=${JVM_VARIANTS// /$'\n'} 99296341Sdelphij INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` 100160814Ssimon if test "x$INVALID_VARIANTS" != x; then 101160814Ssimon AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS]) 102296341Sdelphij AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS]) 103296341Sdelphij fi 104296341Sdelphij 105296341Sdelphij # All "special" variants share the same output directory ("server") 106296341Sdelphij VALID_MULTIPLE_JVM_VARIANTS="server client minimal" 107296341Sdelphij NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'} 108160814Ssimon STACK=${JVM_VARIANTS// /$'\n'} 109296341Sdelphij INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` 110296341Sdelphij if test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then 111160814Ssimon AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.]) 112160814Ssimon fi 113160814Ssimon 114160814Ssimon AC_SUBST(JVM_VARIANTS) 115160814Ssimon AC_SUBST(VALID_JVM_VARIANTS) 116160814Ssimon 117160814Ssimon if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then 118160814Ssimon # zero behaves as a platform and rewrites these values. This is really weird. :( 119160814Ssimon # We are guaranteed that we do not build any other variants when building zero. 120296341Sdelphij HOTSPOT_TARGET_CPU=zero 121160814Ssimon HOTSPOT_TARGET_CPU_ARCH=zero 122160814Ssimon fi 123160814Ssimon]) 124160814Ssimon 125160814Ssimon############################################################################### 126160814Ssimon# Check if dtrace should be enabled and has all prerequisites present. 127160814Ssimon# 128160814SsimonAC_DEFUN_ONCE([HOTSPOT_SETUP_DTRACE], 129160814Ssimon[ 130160814Ssimon # Test for dtrace dependencies 131160814Ssimon AC_ARG_ENABLE([dtrace], [AS_HELP_STRING([--enable-dtrace@<:@=yes/no/auto@:>@], 132160814Ssimon [enable dtrace. Default is auto, where dtrace is enabled if all dependencies 133160814Ssimon are present.])]) 134160814Ssimon 135160814Ssimon DTRACE_DEP_MISSING=false 136160814Ssimon 137160814Ssimon AC_MSG_CHECKING([for dtrace tool]) 138160814Ssimon if test "x$DTRACE" != "x" && test -x "$DTRACE"; then 139160814Ssimon AC_MSG_RESULT([$DTRACE]) 140160814Ssimon else 141160814Ssimon AC_MSG_RESULT([not found, cannot build dtrace]) 142160814Ssimon DTRACE_DEP_MISSING=true 143160814Ssimon fi 144296341Sdelphij 145296341Sdelphij AC_CHECK_HEADERS([sys/sdt.h], [DTRACE_HEADERS_OK=yes],[DTRACE_HEADERS_OK=no]) 146160814Ssimon if test "x$DTRACE_HEADERS_OK" != "xyes"; then 147160814Ssimon DTRACE_DEP_MISSING=true 148160814Ssimon fi 149160814Ssimon 150296341Sdelphij AC_MSG_CHECKING([if dtrace should be built]) 151296341Sdelphij if test "x$enable_dtrace" = "xyes"; then 152160814Ssimon if test "x$DTRACE_DEP_MISSING" = "xtrue"; then 153160814Ssimon AC_MSG_RESULT([no, missing dependencies]) 154296341Sdelphij HELP_MSG_MISSING_DEPENDENCY([dtrace]) 155296341Sdelphij AC_MSG_ERROR([Cannot enable dtrace with missing dependencies. See above. $HELP_MSG]) 156296341Sdelphij else 157296341Sdelphij INCLUDE_DTRACE=true 158296341Sdelphij AC_MSG_RESULT([yes, forced]) 159296341Sdelphij fi 160296341Sdelphij elif test "x$enable_dtrace" = "xno"; then 161160814Ssimon INCLUDE_DTRACE=false 162296341Sdelphij AC_MSG_RESULT([no, forced]) 163296341Sdelphij elif test "x$enable_dtrace" = "xauto" || test "x$enable_dtrace" = "x"; then 164160814Ssimon if test "x$DTRACE_DEP_MISSING" = "xtrue"; then 165296341Sdelphij INCLUDE_DTRACE=false 166296341Sdelphij AC_MSG_RESULT([no, missing dependencies]) 167160814Ssimon else 168296341Sdelphij INCLUDE_DTRACE=true 169296341Sdelphij AC_MSG_RESULT([yes, dependencies present]) 170296341Sdelphij fi 171296341Sdelphij else 172160814Ssimon AC_MSG_ERROR([Invalid value for --enable-dtrace: $enable_dtrace]) 173296341Sdelphij fi 174296341Sdelphij AC_SUBST(INCLUDE_DTRACE) 175296341Sdelphij]) 176296341Sdelphij 177160814Ssimon############################################################################### 178296341Sdelphij# Set up all JVM features for each JVM variant. 179296341Sdelphij# 180296341SdelphijAC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES], 181160814Ssimon[ 182296341Sdelphij # The user can in some cases supply additional jvm features. For the custom 183160814Ssimon # variant, this defines the entire variant. 184296341Sdelphij AC_ARG_WITH([jvm-features], [AS_HELP_STRING([--with-jvm-features], 185296341Sdelphij [additional JVM features to enable (separated by comma), use '--help' to show possible values @<:@none@:>@])]) 186296341Sdelphij if test "x$with_jvm_features" != x; then 187296341Sdelphij AC_MSG_CHECKING([additional JVM features]) 188296341Sdelphij JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'` 189160814Ssimon AC_MSG_RESULT([$JVM_FEATURES]) 190296341Sdelphij fi 191296341Sdelphij 192160814Ssimon # Verify that dependencies are met for explicitly set features. 193296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(jvmti) && ! HOTSPOT_CHECK_JVM_FEATURE(services); then 194160814Ssimon AC_MSG_ERROR([Specified JVM feature 'jvmti' requires feature 'services']) 195296341Sdelphij fi 196296341Sdelphij 197296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(management) && ! HOTSPOT_CHECK_JVM_FEATURE(nmt); then 198296341Sdelphij AC_MSG_ERROR([Specified JVM feature 'management' requires feature 'nmt']) 199160814Ssimon fi 200296341Sdelphij 201296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(jvmci) && ! HOTSPOT_CHECK_JVM_FEATURE(compiler2); then 202160814Ssimon AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2']) 203160814Ssimon fi 204296341Sdelphij 205296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(compiler2) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then 206296341Sdelphij AC_MSG_ERROR([Specified JVM feature 'compiler2' requires feature 'all-gcs']) 207296341Sdelphij fi 208296341Sdelphij 209296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(vm-structs) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then 210296341Sdelphij AC_MSG_ERROR([Specified JVM feature 'vm-structs' requires feature 'all-gcs']) 211296341Sdelphij fi 212296341Sdelphij 213160814Ssimon # Turn on additional features based on other parts of configure 214160814Ssimon if test "x$INCLUDE_DTRACE" = "xtrue"; then 215296341Sdelphij JVM_FEATURES="$JVM_FEATURES dtrace" 216296341Sdelphij else 217296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(dtrace); then 218296341Sdelphij AC_MSG_ERROR([To enable dtrace, you must use --enable-dtrace]) 219296341Sdelphij fi 220296341Sdelphij fi 221296341Sdelphij 222296341Sdelphij if test "x$STATIC_BUILD" = "xtrue"; then 223160814Ssimon JVM_FEATURES="$JVM_FEATURES static-build" 224160814Ssimon else 225296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(static-build); then 226296341Sdelphij AC_MSG_ERROR([To enable static-build, you must use --enable-static-build]) 227296341Sdelphij fi 228296341Sdelphij fi 229296341Sdelphij 230296341Sdelphij if ! HOTSPOT_CHECK_JVM_VARIANT(zero) && ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then 231160814Ssimon if HOTSPOT_CHECK_JVM_FEATURE(zero); then 232296341Sdelphij AC_MSG_ERROR([To enable zero/zeroshark, you must use --with-jvm-variants=zero/zeroshark]) 233296341Sdelphij fi 234296341Sdelphij fi 235296341Sdelphij 236296341Sdelphij if ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then 237296341Sdelphij if HOTSPOT_CHECK_JVM_FEATURE(shark); then 238160814Ssimon AC_MSG_ERROR([To enable shark, you must use --with-jvm-variants=zeroshark]) 239160814Ssimon fi 240296341Sdelphij fi 241296341Sdelphij 242296341Sdelphij # Only enable jvmci on x86_64, sparcv9 and aarch64, and only on server. 243160814Ssimon if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \ 244160814Ssimon test "x$OPENJDK_TARGET_CPU" = "xsparcv9" || \ 245296341Sdelphij test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then 246296341Sdelphij JVM_FEATURES_jvmci="jvmci" 247296341Sdelphij else 248160814Ssimon JVM_FEATURES_jvmci="" 249160814Ssimon fi 250296341Sdelphij 251296341Sdelphij # All variants but minimal (and custom) get these features 252296341Sdelphij NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds" 253160814Ssimon 254160814Ssimon # Enable features depending on variant. 255296341Sdelphij JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci" 256296341Sdelphij JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES" 257296341Sdelphij JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES" 258160814Ssimon JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES" 259160814Ssimon JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES" 260296341Sdelphij JVM_FEATURES_zeroshark="zero shark $NON_MINIMAL_FEATURES $JVM_FEATURES" 261296341Sdelphij JVM_FEATURES_custom="$JVM_FEATURES" 262296341Sdelphij 263296341Sdelphij AC_SUBST(JVM_FEATURES_server) 264160814Ssimon AC_SUBST(JVM_FEATURES_client) 265296341Sdelphij AC_SUBST(JVM_FEATURES_core) 266296341Sdelphij AC_SUBST(JVM_FEATURES_minimal) 267296341Sdelphij AC_SUBST(JVM_FEATURES_zero) 268296341Sdelphij AC_SUBST(JVM_FEATURES_zeroshark) 269296341Sdelphij AC_SUBST(JVM_FEATURES_custom) 270296341Sdelphij 271296341Sdelphij # Used for verification of Makefiles by check-jvm-feature 272296341Sdelphij AC_SUBST(VALID_JVM_FEATURES) 273296341Sdelphij 274296341Sdelphij # We don't support --with-jvm-interpreter anymore, use zero instead. 275296341Sdelphij BASIC_DEPRECATED_ARG_WITH(jvm-interpreter) 276296341Sdelphij]) 277160814Ssimon 278296341Sdelphij############################################################################### 279296341Sdelphij# Validate JVM features once all setup is complete, including custom setup. 280296341Sdelphij# 281296341SdelphijAC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES], 282296341Sdelphij[ 283296341Sdelphij # Keep feature lists sorted and free of duplicates 284296341Sdelphij JVM_FEATURES_server="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_server | $SORT -u))" 285296341Sdelphij JVM_FEATURES_client="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_client | $SORT -u))" 286296341Sdelphij JVM_FEATURES_core="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_core | $SORT -u))" 287160814Ssimon JVM_FEATURES_minimal="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_minimal | $SORT -u))" 288296341Sdelphij JVM_FEATURES_zero="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zero | $SORT -u))" 289296341Sdelphij JVM_FEATURES_zeroshark="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zeroshark | $SORT -u))" 290296341Sdelphij JVM_FEATURES_custom="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_custom | $SORT -u))" 291296341Sdelphij 292160814Ssimon # Validate features 293296341Sdelphij for variant in $JVM_VARIANTS; do 294296341Sdelphij AC_MSG_CHECKING([JVM features for JVM variant '$variant']) 295296341Sdelphij features_var_name=JVM_FEATURES_$variant 296160814Ssimon JVM_FEATURES_TO_TEST=${!features_var_name} 297296341Sdelphij AC_MSG_RESULT([$JVM_FEATURES_TO_TEST]) 298296341Sdelphij NEEDLE=${VALID_JVM_FEATURES// /$'\n'} 299296341Sdelphij STACK=${JVM_FEATURES_TO_TEST// /$'\n'} 300296341Sdelphij INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` 301296341Sdelphij if test "x$INVALID_FEATURES" != x; then 302296341Sdelphij AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES]) 303296341Sdelphij fi 304296341Sdelphij done 305296341Sdelphij]) 306296341Sdelphij 307296341Sdelphij################################################################################ 308296341Sdelphij# Check if gtest should be built 309296341Sdelphij# 310160814SsimonAC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST], 311160814Ssimon[ 312296341Sdelphij AC_ARG_ENABLE([hotspot-gtest], [AS_HELP_STRING([--disable-hotspot-gtest], 313296341Sdelphij [Disables building of the Hotspot unit tests])]) 314296341Sdelphij 315160814Ssimon if test -e "$HOTSPOT_TOPDIR/test/native"; then 316296341Sdelphij GTEST_DIR_EXISTS="true" 317296341Sdelphij else 318296341Sdelphij GTEST_DIR_EXISTS="false" 319296341Sdelphij fi 320160814Ssimon 321160814Ssimon AC_MSG_CHECKING([if Hotspot gtest unit tests should be built]) 322160814Ssimon if test "x$enable_hotspot_gtest" = "xyes"; then 323296341Sdelphij if test "x$GTEST_DIR_EXISTS" = "xtrue"; then 324296341Sdelphij AC_MSG_RESULT([yes, forced]) 325296341Sdelphij BUILD_GTEST="true" 326296341Sdelphij else 327296341Sdelphij AC_MSG_ERROR([Cannot build gtest without the test source]) 328296341Sdelphij fi 329296341Sdelphij elif test "x$enable_hotspot_gtest" = "xno"; then 330296341Sdelphij AC_MSG_RESULT([no, forced]) 331296341Sdelphij BUILD_GTEST="false" 332296341Sdelphij elif test "x$enable_hotspot_gtest" = "x"; then 333296341Sdelphij if test "x$GTEST_DIR_EXISTS" = "xtrue" && test "x$OPENJDK_TARGET_OS" != "xaix"; then 334296341Sdelphij AC_MSG_RESULT([yes]) 335296341Sdelphij BUILD_GTEST="true" 336296341Sdelphij else 337296341Sdelphij AC_MSG_RESULT([no]) 338296341Sdelphij BUILD_GTEST="false" 339296341Sdelphij fi 340296341Sdelphij else 341296341Sdelphij AC_MSG_ERROR([--enable-gtest must be either yes or no]) 342296341Sdelphij fi 343296341Sdelphij 344296341Sdelphij AC_SUBST(BUILD_GTEST) 345296341Sdelphij]) 346296341Sdelphij