hotspot.m4 revision 2024:cc16e2a24f94
1#
2# Copyright (c) 2011, 2016, 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# All valid JVM features, regardless of platform
27VALID_JVM_FEATURES="compiler1 compiler2 zero shark minimal dtrace jvmti jvmci \
28    fprof vm-structs jni-check services management all-gcs nmt cds static-build"
29
30# All valid JVM variants
31VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom"
32
33###############################################################################
34# Check if the specified JVM variant should be built. To be used in shell if
35# constructs, like this:
36# if HOTSPOT_CHECK_JVM_VARIANT(server); then
37#
38# Only valid to use after HOTSPOT_SETUP_JVM_VARIANTS has setup variants.
39
40# Definition kept in one line to allow inlining in if statements.
41# Additional [] needed to keep m4 from mangling shell constructs.
42AC_DEFUN([HOTSPOT_CHECK_JVM_VARIANT],
43[ [ [[ " $JVM_VARIANTS " =~ " $1 " ]] ] ])
44
45###############################################################################
46# Check if the specified JVM features are explicitly enabled. To be used in
47# shell if constructs, like this:
48# if HOTSPOT_CHECK_JVM_FEATURE(jvmti); then
49#
50# Only valid to use after HOTSPOT_SETUP_JVM_FEATURES has setup features.
51
52# Definition kept in one line to allow inlining in if statements.
53# Additional [] needed to keep m4 from mangling shell constructs.
54AC_DEFUN([HOTSPOT_CHECK_JVM_FEATURE],
55[ [ [[ " $JVM_FEATURES " =~ " $1 " ]] ] ])
56
57###############################################################################
58# Check which variants of the JVM that we want to build. Available variants are:
59#   server: normal interpreter, and a tiered C1/C2 compiler
60#   client: normal interpreter, and C1 (no C2 compiler)
61#   minimal: reduced form of client with optional features stripped out
62#   core: normal interpreter only, no compiler
63#   zero: C++ based interpreter only, no compiler
64#   zeroshark: C++ based interpreter, and a llvm-based compiler
65#   custom: baseline JVM with no default features
66#
67AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS],
68[
69  AC_ARG_WITH([jvm-variants], [AS_HELP_STRING([--with-jvm-variants],
70      [JVM variants (separated by commas) to build (server,client,minimal,core,zero,zeroshark,custom) @<:@server@:>@])])
71
72  if test "x$with_jvm_variants" = x; then
73    with_jvm_variants="server"
74  fi
75  JVM_VARIANTS_OPT="$with_jvm_variants"
76
77  # Has the user listed more than one variant?
78  # Additional [] needed to keep m4 from mangling shell constructs.
79  if [ [[ "$JVM_VARIANTS_OPT" =~ "," ]] ]; then
80    BUILDING_MULTIPLE_JVM_VARIANTS=true
81  else
82    BUILDING_MULTIPLE_JVM_VARIANTS=false
83  fi
84  # Replace the commas with AND for use in the build directory name.
85  JVM_VARIANTS_WITH_AND=`$ECHO "$JVM_VARIANTS_OPT" | $SED -e 's/,/AND/g'`
86
87  AC_MSG_CHECKING([which variants of the JVM to build])
88  # JVM_VARIANTS is a space-separated list.
89  # Also use minimal, not minimal1 (which is kept for backwards compatibility).
90  JVM_VARIANTS=`$ECHO $JVM_VARIANTS_OPT | $SED -e 's/,/ /g' -e 's/minimal1/minimal/'`
91  AC_MSG_RESULT([$JVM_VARIANTS])
92
93  # Check that the selected variants are valid
94
95  # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
96  INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
97  if test "x$INVALID_VARIANTS" != x; then
98    AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS])
99    AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS])
100  fi
101
102  # All "special" variants share the same output directory ("server")
103  VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
104  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
105  if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
106    AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.])
107  fi
108
109  AC_SUBST(JVM_VARIANTS)
110  AC_SUBST(VALID_JVM_VARIANTS)
111
112  if HOTSPOT_CHECK_JVM_VARIANT(zero) || HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
113    # zero behaves as a platform and rewrites these values. This is really weird. :(
114    # We are guaranteed that we do not build any other variants when building zero.
115    HOTSPOT_TARGET_CPU=zero
116    HOTSPOT_TARGET_CPU_ARCH=zero
117  fi
118])
119
120###############################################################################
121# Check if dtrace should be enabled and has all prerequisites present.
122#
123AC_DEFUN_ONCE([HOTSPOT_SETUP_DTRACE],
124[
125  # Test for dtrace dependencies
126  AC_ARG_ENABLE([dtrace], [AS_HELP_STRING([--enable-dtrace@<:@=yes/no/auto@:>@],
127      [enable dtrace. Default is auto, where dtrace is enabled if all dependencies
128      are present.])])
129
130  DTRACE_DEP_MISSING=false
131
132  AC_MSG_CHECKING([for dtrace tool])
133  if test "x$DTRACE" != "x" && test -x "$DTRACE"; then
134    AC_MSG_RESULT([$DTRACE])
135  else
136    AC_MSG_RESULT([not found, cannot build dtrace])
137    DTRACE_DEP_MISSING=true
138  fi
139
140  AC_CHECK_HEADERS([sys/sdt.h], [DTRACE_HEADERS_OK=yes],[DTRACE_HEADERS_OK=no])
141  if test "x$DTRACE_HEADERS_OK" != "xyes"; then
142    DTRACE_DEP_MISSING=true
143  fi
144
145  AC_MSG_CHECKING([if dtrace should be built])
146  if test "x$enable_dtrace" = "xyes"; then
147    if test "x$DTRACE_DEP_MISSING" = "xtrue"; then
148      AC_MSG_RESULT([no, missing dependencies])
149      HELP_MSG_MISSING_DEPENDENCY([dtrace])
150      AC_MSG_ERROR([Cannot enable dtrace with missing dependencies. See above. $HELP_MSG])
151    else
152      INCLUDE_DTRACE=true
153      AC_MSG_RESULT([yes, forced])
154    fi
155  elif test "x$enable_dtrace" = "xno"; then
156    INCLUDE_DTRACE=false
157    AC_MSG_RESULT([no, forced])
158  elif test "x$enable_dtrace" = "xauto" || test "x$enable_dtrace" = "x"; then
159    if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK" != "xtrue"; then
160      INCLUDE_DTRACE=false
161      AC_MSG_RESULT([no, non-open linux build])
162    elif test "x$DTRACE_DEP_MISSING" = "xtrue"; then
163      INCLUDE_DTRACE=false
164      AC_MSG_RESULT([no, missing dependencies])
165    else
166      INCLUDE_DTRACE=true
167      AC_MSG_RESULT([yes, dependencies present])
168    fi
169  else
170    AC_MSG_ERROR([Invalid value for --enable-dtrace: $enable_dtrace])
171  fi
172  AC_SUBST(INCLUDE_DTRACE)
173])
174
175###############################################################################
176# Set up all JVM features for each JVM variant.
177#
178AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
179[
180  # The user can in some cases supply additional jvm features. For the custom
181  # variant, this defines the entire variant.
182  AC_ARG_WITH([jvm-features], [AS_HELP_STRING([--with-jvm-features],
183      [additional JVM features to enable (separated by comma),  use '--help' to show possible values @<:@none@:>@])])
184  if test "x$with_jvm_features" != x; then
185    AC_MSG_CHECKING([additional JVM features])
186    JVM_FEATURES=`$ECHO $with_jvm_features | $SED -e 's/,/ /g'`
187    AC_MSG_RESULT([$JVM_FEATURES])
188  fi
189
190  # Verify that dependencies are met for explicitly set features.
191  if HOTSPOT_CHECK_JVM_FEATURE(jvmti) && ! HOTSPOT_CHECK_JVM_FEATURE(services); then
192    AC_MSG_ERROR([Specified JVM feature 'jvmti' requires feature 'services'])
193  fi
194
195  if HOTSPOT_CHECK_JVM_FEATURE(management) && ! HOTSPOT_CHECK_JVM_FEATURE(nmt); then
196    AC_MSG_ERROR([Specified JVM feature 'management' requires feature 'nmt'])
197  fi
198
199  if HOTSPOT_CHECK_JVM_FEATURE(jvmci) && ! HOTSPOT_CHECK_JVM_FEATURE(compiler2); then
200    AC_MSG_ERROR([Specified JVM feature 'jvmci' requires feature 'compiler2'])
201  fi
202
203  if HOTSPOT_CHECK_JVM_FEATURE(compiler2) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
204    AC_MSG_ERROR([Specified JVM feature 'compiler2' requires feature 'all-gcs'])
205  fi
206
207  if HOTSPOT_CHECK_JVM_FEATURE(vm-structs) && ! HOTSPOT_CHECK_JVM_FEATURE(all-gcs); then
208    AC_MSG_ERROR([Specified JVM feature 'vm-structs' requires feature 'all-gcs'])
209  fi
210
211  # Turn on additional features based on other parts of configure
212  if test "x$INCLUDE_DTRACE" = "xtrue"; then
213    JVM_FEATURES="$JVM_FEATURES dtrace"
214  else
215    if HOTSPOT_CHECK_JVM_FEATURE(dtrace); then
216      AC_MSG_ERROR([To enable dtrace, you must use --enable-dtrace])
217    fi
218  fi
219
220  if test "x$STATIC_BUILD" = "xtrue"; then
221    JVM_FEATURES="$JVM_FEATURES static-build"
222  else
223    if HOTSPOT_CHECK_JVM_FEATURE(static-build); then
224      AC_MSG_ERROR([To enable static-build, you must use --enable-static-build])
225    fi
226  fi
227
228  if ! HOTSPOT_CHECK_JVM_VARIANT(zero) && ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
229    if HOTSPOT_CHECK_JVM_FEATURE(zero); then
230      AC_MSG_ERROR([To enable zero/zeroshark, you must use --with-jvm-variants=zero/zeroshark])
231    fi
232  fi
233
234  if ! HOTSPOT_CHECK_JVM_VARIANT(zeroshark); then
235    if HOTSPOT_CHECK_JVM_FEATURE(shark); then
236      AC_MSG_ERROR([To enable shark, you must use --with-jvm-variants=zeroshark])
237    fi
238  fi
239
240  # Only enable jvmci on x86_64, sparcv9 and aarch64, and only on server.
241  if test "x$OPENJDK_TARGET_CPU" = "xx86_64" || \
242      test "x$OPENJDK_TARGET_CPU" = "xsparcv9" || \
243      test "x$OPENJDK_TARGET_CPU" = "xaarch64" ; then
244    JVM_FEATURES_jvmci="jvmci"
245  else
246    JVM_FEATURES_jvmci=""
247  fi
248
249  # All variants but minimal (and custom) get these features
250  NON_MINIMAL_FEATURES="$NON_MINIMAL_FEATURES jvmti fprof vm-structs jni-check services management all-gcs nmt cds"
251
252  # Enable features depending on variant.
253  JVM_FEATURES_server="compiler1 compiler2 $NON_MINIMAL_FEATURES $JVM_FEATURES $JVM_FEATURES_jvmci"
254  JVM_FEATURES_client="compiler1 $NON_MINIMAL_FEATURES $JVM_FEATURES"
255  JVM_FEATURES_core="$NON_MINIMAL_FEATURES $JVM_FEATURES"
256  JVM_FEATURES_minimal="compiler1 minimal $JVM_FEATURES"
257  JVM_FEATURES_zero="zero $NON_MINIMAL_FEATURES $JVM_FEATURES"
258  JVM_FEATURES_zeroshark="zero shark $NON_MINIMAL_FEATURES $JVM_FEATURES"
259  JVM_FEATURES_custom="$JVM_FEATURES"
260
261  AC_SUBST(JVM_FEATURES_server)
262  AC_SUBST(JVM_FEATURES_client)
263  AC_SUBST(JVM_FEATURES_core)
264  AC_SUBST(JVM_FEATURES_minimal)
265  AC_SUBST(JVM_FEATURES_zero)
266  AC_SUBST(JVM_FEATURES_zeroshark)
267  AC_SUBST(JVM_FEATURES_custom)
268
269  # Used for verification of Makefiles by check-jvm-feature
270  AC_SUBST(VALID_JVM_FEATURES)
271
272  # We don't support --with-jvm-interpreter anymore, use zero instead.
273  BASIC_DEPRECATED_ARG_WITH(jvm-interpreter)
274])
275
276###############################################################################
277# Validate JVM features once all setup is complete, including custom setup.
278#
279AC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES],
280[
281  # Keep feature lists sorted and free of duplicates
282  JVM_FEATURES_server="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_server | $SORT -u))"
283  JVM_FEATURES_client="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_client | $SORT -u))"
284  JVM_FEATURES_core="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_core | $SORT -u))"
285  JVM_FEATURES_minimal="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_minimal | $SORT -u))"
286  JVM_FEATURES_zero="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zero | $SORT -u))"
287  JVM_FEATURES_zeroshark="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_zeroshark | $SORT -u))"
288  JVM_FEATURES_custom="$($ECHO $($PRINTF '%s\n' $JVM_FEATURES_custom | $SORT -u))"
289
290  # Validate features
291  for variant in $JVM_VARIANTS; do
292    AC_MSG_CHECKING([JVM features for JVM variant '$variant'])
293    features_var_name=JVM_FEATURES_$variant
294    JVM_FEATURES_TO_TEST=${!features_var_name}
295    AC_MSG_RESULT([$JVM_FEATURES_TO_TEST])
296    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"`
297    if test "x$INVALID_FEATURES" != x; then
298      AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES])
299    fi
300  done
301])
302
303###############################################################################
304# Support for old hotspot build. Remove once new hotspot build has proven
305# to work satisfactory.
306#
307AC_DEFUN_ONCE([HOTSPOT_SETUP_LEGACY_BUILD],
308[
309  AC_ARG_ENABLE(new-hotspot-build, [AS_HELP_STRING([--disable-new-hotspot-build],
310      [disable the new hotspot build system (use the old) @<:@enabled@:>@])])
311
312   if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then
313     USE_NEW_HOTSPOT_BUILD=true
314   else
315     USE_NEW_HOTSPOT_BUILD=false
316   fi
317  AC_SUBST(USE_NEW_HOTSPOT_BUILD)
318
319  case $HOTSPOT_DEBUG_LEVEL in
320    product )
321      VARIANT="OPT"
322      FASTDEBUG="false"
323      DEBUG_CLASSFILES="false"
324      ;;
325    fastdebug )
326      VARIANT="DBG"
327      FASTDEBUG="true"
328      DEBUG_CLASSFILES="true"
329      ;;
330    debug )
331      VARIANT="DBG"
332      FASTDEBUG="false"
333      DEBUG_CLASSFILES="true"
334      ;;
335    optimized )
336      VARIANT="OPT"
337      FASTDEBUG="false"
338      DEBUG_CLASSFILES="false"
339      ;;
340  esac
341  AC_SUBST(VARIANT)
342  AC_SUBST(FASTDEBUG)
343  AC_SUBST(DEBUG_CLASSFILES)
344
345  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
346    MACOSX_UNIVERSAL="true"
347  fi
348
349  AC_SUBST(MACOSX_UNIVERSAL)
350
351  # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility
352  JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'`
353
354  JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
355  JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'`
356  JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'`
357  JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'`
358  JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
359  JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
360  JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'`
361
362  #####
363  # Generate the legacy makefile targets for hotspot.
364  HOTSPOT_TARGET=""
365
366  if test "x$JVM_VARIANT_SERVER" = xtrue; then
367    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
368  fi
369
370  if test "x$JVM_VARIANT_CLIENT" = xtrue; then
371    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
372  fi
373
374  if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
375    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 "
376  fi
377
378  if test "x$JVM_VARIANT_ZERO" = xtrue; then
379    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
380  fi
381
382  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
383    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
384  fi
385
386  if test "x$JVM_VARIANT_CORE" = xtrue; then
387    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core "
388  fi
389
390  HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL"
391
392  # On Macosx universal binaries are produced, but they only contain
393  # 64 bit intel. This invalidates control of which jvms are built
394  # from configure, but only server is valid anyway. Fix this
395  # when hotspot makefiles are rewritten.
396  if test "x$MACOSX_UNIVERSAL" = xtrue; then
397    HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL}
398  fi
399
400  HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
401  AC_SUBST(HOTSPOT_MAKE_ARGS)
402
403  # Control wether Hotspot runs Queens test after build.
404  AC_ARG_ENABLE([hotspot-test-in-build], [AS_HELP_STRING([--enable-hotspot-test-in-build],
405      [run the Queens test after Hotspot build @<:@disabled@:>@])],,
406      [enable_hotspot_test_in_build=no])
407  if test "x$enable_hotspot_test_in_build" = "xyes"; then
408    TEST_IN_BUILD=true
409  else
410    TEST_IN_BUILD=false
411  fi
412  AC_SUBST(TEST_IN_BUILD)
413
414  if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then
415    if test "x$JVM_VARIANT_CLIENT" = xtrue; then
416      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
417        AC_MSG_ERROR([You cannot build a client JVM for a 64-bit machine.])
418      fi
419    fi
420    if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
421      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
422        AC_MSG_ERROR([You cannot build a minimal JVM for a 64-bit machine.])
423      fi
424    fi
425    if test "x$JVM_VARIANT_CUSTOM" = xtrue; then
426        AC_MSG_ERROR([You cannot build a custom JVM using the old hotspot build system.])
427    fi
428  fi
429
430  AC_SUBST(JVM_VARIANTS_COMMA)
431  AC_SUBST(JVM_VARIANT_SERVER)
432  AC_SUBST(JVM_VARIANT_CLIENT)
433  AC_SUBST(JVM_VARIANT_MINIMAL1)
434  AC_SUBST(JVM_VARIANT_HOTSPOT)
435  AC_SUBST(JVM_VARIANT_ZERO)
436  AC_SUBST(JVM_VARIANT_ZEROSHARK)
437  AC_SUBST(JVM_VARIANT_CORE)
438])
439