boot-jdk.m4 revision 2413:3e4c1bd5ad4c
1207536Smav# 2207536Smav# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. 3207536Smav# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4207536Smav# 5207536Smav# This code is free software; you can redistribute it and/or modify it 6207536Smav# under the terms of the GNU General Public License version 2 only, as 7207536Smav# published by the Free Software Foundation. Oracle designates this 8207536Smav# particular file as subject to the "Classpath" exception as provided 9207536Smav# by Oracle in the LICENSE file that accompanied this code. 10207536Smav# 11207536Smav# This code is distributed in the hope that it will be useful, but WITHOUT 12207536Smav# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13207536Smav# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14207536Smav# version 2 for more details (a copy is included in the LICENSE file that 15207536Smav# accompanied this code). 16207536Smav# 17207536Smav# You should have received a copy of the GNU General Public License version 18207536Smav# 2 along with this work; if not, write to the Free Software Foundation, 19207536Smav# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20207536Smav# 21207536Smav# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22207536Smav# or visit www.oracle.com if you need additional information or have any 23207536Smav# questions. 24207536Smav# 25207536Smav 26207536Smav######################################################################## 27207536Smav# This file handles detection of the Boot JDK. The Boot JDK detection 28207536Smav# process has been developed as a response to solve a complex real-world 29207536Smav# problem. Initially, it was simple, but it has grown as platform after 30207536Smav# platform, idiosyncracy after idiosyncracy has been supported. 31207536Smav# 32207536Smav# The basic idea is this: 33207536Smav# 1) You need an acceptable *) JDK to use as a Boot JDK 34207536Smav# 2) There are several ways to locate a JDK, that are mostly platform 35207536Smav# dependent **) 36207536Smav# 3) You can have multiple JDKs installed 37207536Smav# 4) If possible, configure should try to dig out an acceptable JDK 38207536Smav# automatically, without having to resort to command-line options 39207536Smav# 40207536Smav# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with 41207536Smav# javac) and not a JRE, etc. 42207536Smav# 43207536Smav# **) On Windows we typically use a well-known path. 44207536Smav# On MacOSX we typically use the tool java_home. 45207536Smav# On Linux we typically find javac in the $PATH, and then follow a 46207536Smav# chain of symlinks that often ends up in a real JDK. 47207536Smav# 48207536Smav# This leads to the code where we check in different ways to locate a 49207536Smav# JDK, and if one is found, check if it is acceptable. If not, we print 50207536Smav# our reasons for rejecting it (useful when debugging non-working 51207536Smav# configure situations) and continue checking the next one. 52207536Smav######################################################################## 53207536Smav 54207536Smav# Execute the check given as argument, and verify the result 55207536Smav# If the Boot JDK was previously found, do nothing 56207536Smav# $1 A command line (typically autoconf macro) to execute 57207536SmavAC_DEFUN([BOOTJDK_DO_CHECK], 58207536Smav[ 59207536Smav if test "x$BOOT_JDK_FOUND" = xno; then 60207536Smav # Now execute the test 61207536Smav $1 62207536Smav 63207536Smav # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 64232511Sraj if test "x$BOOT_JDK_FOUND" = xmaybe; then 65232511Sraj # Do we have a bin/java? 66232511Sraj if test ! -x "$BOOT_JDK/bin/java"; then 67207536Smav AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 68207536Smav BOOT_JDK_FOUND=no 69207536Smav else 70207536Smav # Do we have a bin/javac? 71207536Smav if test ! -x "$BOOT_JDK/bin/javac"; then 72207536Smav AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 73207536Smav AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 74207536Smav BOOT_JDK_FOUND=no 75207536Smav else 76207536Smav # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 77207536Smav BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1` 78207536Smav 79207536Smav # Extra M4 quote needed to protect [] in grep expression. 80207536Smav [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"|(1\.[89]\.)'`] 81207536Smav if test "x$FOUND_CORRECT_VERSION" = x; then 82207536Smav AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 83207536Smav AC_MSG_NOTICE([(Your Boot JDK must be version 8 or 9)]) 84207536Smav BOOT_JDK_FOUND=no 85207536Smav else 86207536Smav # We're done! :-) 87207536Smav BOOT_JDK_FOUND=yes 88207536Smav BASIC_FIXUP_PATH(BOOT_JDK) 89207536Smav AC_MSG_CHECKING([for Boot JDK]) 90207536Smav AC_MSG_RESULT([$BOOT_JDK]) 91207536Smav AC_MSG_CHECKING([Boot JDK version]) 92207536Smav BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 93207536Smav AC_MSG_RESULT([$BOOT_JDK_VERSION]) 94207536Smav fi # end check jdk version 95207536Smav fi # end check javac 96207536Smav fi # end check java 97207536Smav fi # end check boot jdk found 98207536Smav fi 99207536Smav]) 100207536Smav 101207536Smav# Test: Is bootjdk explicitly set by command line arguments? 102207536SmavAC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 103207536Smav[ 104207536Smav if test "x$with_boot_jdk" != x; then 105207536Smav BOOT_JDK=$with_boot_jdk 106207536Smav BOOT_JDK_FOUND=maybe 107207536Smav AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 108207536Smav fi 109207536Smav]) 110207536Smav 111207536Smav# Test: Is $JAVA_HOME set? 112207536SmavAC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 113207536Smav[ 114207536Smav if test "x$JAVA_HOME" != x; then 115207536Smav JAVA_HOME_PROCESSED="$JAVA_HOME" 116207536Smav BASIC_FIXUP_PATH(JAVA_HOME_PROCESSED) 117207536Smav if test ! -d "$JAVA_HOME_PROCESSED"; then 118207536Smav AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 119207536Smav else 120207536Smav # Aha, the user has set a JAVA_HOME 121207536Smav # let us use that as the Boot JDK. 122207536Smav BOOT_JDK="$JAVA_HOME_PROCESSED" 123207536Smav BOOT_JDK_FOUND=maybe 124207536Smav AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 125207536Smav fi 126207536Smav fi 127207536Smav]) 128207536Smav 129207536Smav# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 130207536SmavAC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 131207536Smav[ 132207536Smav AC_PATH_PROG(JAVAC_CHECK, javac) 133207536Smav AC_PATH_PROG(JAVA_CHECK, java) 134207536Smav BINARY="$JAVAC_CHECK" 135207536Smav if test "x$JAVAC_CHECK" = x; then 136207536Smav BINARY="$JAVA_CHECK" 137207536Smav fi 138207536Smav if test "x$BINARY" != x; then 139207536Smav # So there is a java(c) binary, it might be part of a JDK. 140207536Smav # Lets find the JDK/JRE directory by following symbolic links. 141207536Smav # Linux/GNU systems often have links from /usr/bin/java to 142207536Smav # /etc/alternatives/java to the real JDK binary. 143207536Smav BASIC_REMOVE_SYMBOLIC_LINKS(BINARY) 144207536Smav BOOT_JDK=`dirname "$BINARY"` 145207536Smav BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 146207536Smav if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 147207536Smav # Looks like we found ourselves an JDK 148207536Smav BOOT_JDK_FOUND=maybe 149207536Smav AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 150207536Smav fi 151207536Smav fi 152207536Smav]) 153207536Smav 154207536Smav# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 155207536Smav# $1: Argument to the java_home binary (optional) 156207536SmavAC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 157207536Smav[ 158207536Smav if test -x /usr/libexec/java_home; then 159207536Smav BOOT_JDK=`/usr/libexec/java_home $1` 160207536Smav BOOT_JDK_FOUND=maybe 161207536Smav AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1]) 162207536Smav fi 163207536Smav]) 164207536Smav 165207536Smav# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 166207536SmavAC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR], 167207536Smav[ 168207536Smav if test "x$OPENJDK_TARGET_OS" = xmacosx; then 169207536Smav # First check at user selected default 170207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()]) 171207536Smav # If that did not work out (e.g. too old), try explicit versions instead 172207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.9])]) 173207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.8])]) 174207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.7])]) 175207536Smav fi 176207536Smav]) 177207536Smav 178207536Smav# Look for a jdk in the given path. If there are multiple, try to select the newest. 179207536Smav# If found, set BOOT_JDK and BOOT_JDK_FOUND. 180207536Smav# $1 = Path to directory containing jdk installations. 181207536Smav# $2 = String to append to the found JDK directory to get the proper JDK home 182207536SmavAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 183207536Smav[ 184207536Smav BOOT_JDK_PREFIX="$1" 185207536Smav BOOT_JDK_SUFFIX="$2" 186207536Smav ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 187207536Smav if test "x$ALL_JDKS_FOUND" != x; then 188207536Smav for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 189207536Smav BOOTJDK_DO_CHECK([ 190207536Smav BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 191207536Smav if test -d "$BOOT_JDK"; then 192207536Smav BOOT_JDK_FOUND=maybe 193207536Smav AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 194207536Smav fi 195207536Smav ]) 196207536Smav done 197207536Smav fi 198207536Smav]) 199207536Smav 200207536Smav# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 201207536Smav# environmental variable as base for where to look. 202207536Smav# $1 Name of an environmal variable, assumed to point to the Program Files directory. 203207536SmavAC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 204207536Smav[ 205207536Smav if test "x[$]$1" != x; then 206207536Smav VIRTUAL_DIR="[$]$1/Java" 207207536Smav BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VIRTUAL_DIR) 208207536Smav BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 209207536Smav fi 210207536Smav]) 211207536Smav 212207536Smav# Test: Is there a JDK installed in default, well-known locations? 213207536SmavAC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 214207536Smav[ 215207536Smav if test "x$OPENJDK_TARGET_OS" = xwindows; then 216207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 217207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 218207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 219207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 220207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 221207536Smav elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 222207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 223207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 224207536Smav elif test "x$OPENJDK_TARGET_OS" = xlinux; then 225207536Smav BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 226207536Smav fi 227207536Smav]) 228207536Smav 229207536Smav# Check that a command-line tool in the Boot JDK is correct 230207536Smav# $1 = name of variable to assign 231207536Smav# $2 = name of binary 232207536SmavAC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 233207536Smav[ 234207536Smav # Use user overridden value if available, otherwise locate tool in the Boot JDK. 235207536Smav BASIC_SETUP_TOOL($1, 236207536Smav [ 237207536Smav AC_MSG_CHECKING([for $2 in Boot JDK]) 238207536Smav $1=$BOOT_JDK/bin/$2 239207536Smav if test ! -x [$]$1; then 240207536Smav AC_MSG_RESULT(not found) 241207536Smav AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk]) 242207536Smav AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 243207536Smav fi 244207536Smav AC_MSG_RESULT(ok) 245207536Smav AC_SUBST($1) 246207536Smav ]) 247207536Smav]) 248207536Smav 249207536Smav############################################################################### 250207536Smav# 251207536Smav# We need a Boot JDK to bootstrap the build. 252207536Smav# 253207536Smav 254207536SmavAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 255207536Smav[ 256207536Smav BOOT_JDK_FOUND=no 257207536Smav AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 258207536Smav [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 259207536Smav 260207536Smav # We look for the Boot JDK through various means, going from more certain to 261207536Smav # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 262207536Smav # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 263207536Smav # must check if this is indeed valid; otherwise we'll continue looking. 264207536Smav 265207536Smav # Test: Is bootjdk explicitly set by command line arguments? 266207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 267207536Smav if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 268207536Smav # Having specified an argument which is incorrect will produce an instant failure; 269207536Smav # we should not go on looking 270207536Smav AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 271207536Smav fi 272207536Smav 273207536Smav # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 274207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR]) 275207536Smav 276207536Smav # Test: Is $JAVA_HOME set? 277207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 278207536Smav 279207536Smav # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 280207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 281207536Smav 282207536Smav # Test: Is there a JDK installed in default, well-known locations? 283207536Smav BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 284207536Smav 285207536Smav # If we haven't found anything yet, we've truly lost. Give up. 286207536Smav if test "x$BOOT_JDK_FOUND" = xno; then 287207536Smav HELP_MSG_MISSING_DEPENDENCY([openjdk]) 288207536Smav AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 289207536Smav AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk]) 290207536Smav AC_MSG_ERROR([Cannot continue]) 291207536Smav fi 292207536Smav 293207536Smav AC_SUBST(BOOT_JDK) 294207536Smav 295207536Smav # Setup tools from the Boot JDK. 296207536Smav BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) 297207536Smav BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) 298207536Smav BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH, javah) 299207536Smav BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) 300207536Smav BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner) 301207536Smav 302207536Smav # Finally, set some other options... 303207536Smav 304207536Smav # When compiling code to be executed by the Boot JDK, force jdk8 compatibility. 305207536Smav BOOT_JDK_SOURCETARGET="-source 8 -target 8" 306207536Smav AC_SUBST(BOOT_JDK_SOURCETARGET) 307207536Smav 308207536Smav AC_MSG_CHECKING([if Boot JDK supports modules]) 309207536Smav if "$JAVA" --list-modules > /dev/null 2>&1; then 310207536Smav AC_MSG_RESULT([yes]) 311207536Smav BOOT_JDK_MODULAR="true" 312207536Smav else 313207536Smav AC_MSG_RESULT([no]) 314207536Smav BOOT_JDK_MODULAR="false" 315207536Smav fi 316207536Smav AC_SUBST(BOOT_JDK_MODULAR) 317207536Smav 318207536Smav AC_SUBST(JAVAC_FLAGS) 319207536Smav 320207536Smav # Check if the boot jdk is 32 or 64 bit 321207536Smav if "$JAVA" -d64 -version > /dev/null 2>&1; then 322207536Smav BOOT_JDK_BITS="64" 323207536Smav else 324207536Smav BOOT_JDK_BITS="32" 325207536Smav fi 326207536Smav AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits]) 327207536Smav AC_MSG_RESULT([$BOOT_JDK_BITS]) 328207536Smav AC_SUBST(BOOT_JDK_BITS) 329207536Smav]) 330207536Smav 331207536SmavAC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 332207536Smav[ 333207536Smav ############################################################################## 334207536Smav # 335207536Smav # Specify jvm options for anything that is run with the Boot JDK. 336207536Smav # Not all JVM:s accept the same arguments on the command line. 337207536Smav # 338207536Smav AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 339207536Smav [specify JVM arguments to be passed to all java invocations of boot JDK, overriding the default values, 340207536Smav e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])]) 341207536Smav 342207536Smav AC_MSG_CHECKING([flags for boot jdk java command] ) 343207536Smav 344207536Smav # Disable special log output when a debug build is used as Boot JDK... 345207536Smav ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA]) 346207536Smav 347207536Smav # Force en-US environment 348207536Smav ADD_JVM_ARG_IF_OK([-Duser.language=en -Duser.country=US],boot_jdk_jvmargs,[$JAVA]) 349207536Smav 350207536Smav # Apply user provided options. 351207536Smav ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA]) 352207536Smav 353207536Smav AC_MSG_RESULT([$boot_jdk_jvmargs]) 354207536Smav 355207536Smav # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs 356207536Smav JAVA_FLAGS=$boot_jdk_jvmargs 357207536Smav AC_SUBST(JAVA_FLAGS) 358207536Smav 359207536Smav 360207536Smav AC_MSG_CHECKING([flags for boot jdk java command for big workloads]) 361207536Smav 362207536Smav # Starting amount of heap memory. 363207536Smav ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA]) 364207536Smav BOOTCYCLE_JVM_ARGS_BIG=-Xms64M 365207536Smav 366207536Smav # Maximum amount of heap memory and stack size. 367207536Smav JVM_HEAP_LIMIT_32="1024" 368207536Smav # Running a 64 bit JVM allows for and requires a bigger heap 369207536Smav JVM_HEAP_LIMIT_64="1600" 370207536Smav STACK_SIZE_32=768 371207536Smav STACK_SIZE_64=1536 372207536Smav JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2` 373207536Smav if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then 374207536Smav JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL 375207536Smav fi 376207536Smav if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then 377207536Smav JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL 378207536Smav fi 379207536Smav if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then 380207536Smav JVM_HEAP_LIMIT_32=512 381207536Smav JVM_HEAP_LIMIT_64=512 382207536Smav fi 383207536Smav 384207536Smav if test "x$BOOT_JDK_BITS" = "x32"; then 385207536Smav STACK_SIZE=$STACK_SIZE_32 386207536Smav JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32 387207536Smav else 388207536Smav STACK_SIZE=$STACK_SIZE_64 389207536Smav JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64 390207536Smav fi 391207536Smav ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA]) 392207536Smav ADD_JVM_ARG_IF_OK([-XX:ThreadStackSize=$STACK_SIZE],boot_jdk_jvmargs_big,[$JAVA]) 393207536Smav 394207536Smav AC_MSG_RESULT([$boot_jdk_jvmargs_big]) 395207536Smav 396207536Smav JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big 397207536Smav AC_SUBST(JAVA_FLAGS_BIG) 398207536Smav 399207536Smav if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then 400207536Smav BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32 401207536Smav BOOTCYCLE_STACK_SIZE=$STACK_SIZE_32 402207536Smav else 403207536Smav BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64 404207536Smav BOOTCYCLE_STACK_SIZE=$STACK_SIZE_64 405207536Smav fi 406207536Smav BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M" 407207536Smav BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -XX:ThreadStackSize=$BOOTCYCLE_STACK_SIZE" 408207536Smav AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads]) 409207536Smav AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG]) 410207536Smav AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG) 411207536Smav 412207536Smav # By default, the main javac compilations use big 413207536Smav JAVA_FLAGS_JAVAC="$JAVA_FLAGS_BIG" 414207536Smav AC_SUBST(JAVA_FLAGS_JAVAC) 415207536Smav 416207536Smav AC_MSG_CHECKING([flags for boot jdk java command for small workloads]) 417207536Smav 418207536Smav # Use serial gc for small short lived tools if possible 419207536Smav ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA]) 420207536Smav ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA]) 421207536Smav ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA]) 422207536Smav ADD_JVM_ARG_IF_OK([-XX:TieredStopAtLevel=1],boot_jdk_jvmargs_small,[$JAVA]) 423207536Smav 424207536Smav AC_MSG_RESULT([$boot_jdk_jvmargs_small]) 425207536Smav 426207536Smav JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small 427207536Smav AC_SUBST(JAVA_FLAGS_SMALL) 428207536Smav 429207536Smav JAVA_TOOL_FLAGS_SMALL="" 430207536Smav for f in $JAVA_FLAGS_SMALL; do 431207536Smav JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" 432207536Smav done 433207536Smav AC_SUBST(JAVA_TOOL_FLAGS_SMALL) 434207536Smav]) 435207536Smav 436207536Smav# BUILD_JDK: the location of the latest JDK that can run 437207536Smav# on the host system and supports the target class file version 438207536Smav# generated in this JDK build. This variable should only be 439207536Smav# used after the launchers are built. 440207536Smav# 441207536Smav 442207536Smav# Execute the check given as argument, and verify the result. 443207536Smav# If the JDK was previously found, do nothing. 444207536Smav# $1 A command line (typically autoconf macro) to execute 445207536SmavAC_DEFUN([BOOTJDK_CHECK_BUILD_JDK], 446207536Smav[ 447207536Smav if test "x$BUILD_JDK_FOUND" = xno; then 448207536Smav # Execute the test 449207536Smav $1 450207536Smav 451207536Smav # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 452207536Smav if test "x$BUILD_JDK_FOUND" = xmaybe; then 453207536Smav # Do we have a bin/java? 454207536Smav if test ! -x "$BUILD_JDK/bin/java"; then 455207536Smav AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/java; ignoring]) 456207536Smav BUILD_JDK_FOUND=no 457207536Smav elif test ! -x "$BUILD_JDK/bin/jlink"; then 458207536Smav AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jlink; ignoring]) 459207536Smav BUILD_JDK_FOUND=no 460207536Smav elif test ! -x "$BUILD_JDK/bin/jmod"; then 461207536Smav AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jmod; ignoring]) 462207536Smav BUILD_JDK_FOUND=no 463207536Smav elif test ! -x "$BUILD_JDK/bin/javac"; then 464207536Smav # Do we have a bin/javac? 465207536Smav AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/javac; ignoring]) 466207536Smav AC_MSG_NOTICE([(This might be a JRE instead of an JDK)]) 467207536Smav BUILD_JDK_FOUND=no 468207536Smav else 469207536Smav # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 470207536Smav BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $HEAD -n 1` 471207536Smav 472207536Smav # Extra M4 quote needed to protect [] in grep expression. 473207536Smav [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP '\"9([\.+-].*)?\"'`] 474207536Smav if test "x$FOUND_CORRECT_VERSION" = x; then 475207536Smav AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring]) 476207536Smav AC_MSG_NOTICE([(Your Build JDK must be version 9)]) 477207536Smav BUILD_JDK_FOUND=no 478207536Smav else 479207536Smav # We're done! 480207536Smav BUILD_JDK_FOUND=yes 481207536Smav BASIC_FIXUP_PATH(BUILD_JDK) 482207536Smav AC_MSG_CHECKING([for Build JDK]) 483207536Smav AC_MSG_RESULT([$BUILD_JDK]) 484207536Smav AC_MSG_CHECKING([Build JDK version]) 485207536Smav BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 486207536Smav AC_MSG_RESULT([$BUILD_JDK_VERSION]) 487207536Smav fi # end check jdk version 488207536Smav fi # end check java 489207536Smav fi # end check build jdk found 490207536Smav fi 491207536Smav]) 492207536Smav 493207536Smav# By default the BUILD_JDK is the JDK_OUTPUTDIR. If the target architecture 494207536Smav# is different than the host system doing the build (e.g. cross-compilation), 495207536Smav# a special BUILD_JDK is built as part of the build process. An external 496207536Smav# prebuilt BUILD_JDK can also be supplied. 497207536SmavAC_DEFUN([BOOTJDK_SETUP_BUILD_JDK], 498207536Smav[ 499207536Smav AC_ARG_WITH(build-jdk, [AS_HELP_STRING([--with-build-jdk], 500207536Smav [path to JDK of same version as is being built@<:@the newly built JDK@:>@])]) 501207536Smav 502207536Smav CREATE_BUILDJDK=false 503207536Smav EXTERNAL_BUILDJDK=false 504207536Smav BUILD_JDK_FOUND="no" 505207536Smav if test "x$with_build_jdk" != "x"; then 506207536Smav BOOTJDK_CHECK_BUILD_JDK([ 507207536Smav if test "x$with_build_jdk" != x; then 508207536Smav BUILD_JDK=$with_build_jdk 509207536Smav BUILD_JDK_FOUND=maybe 510207536Smav AC_MSG_NOTICE([Found potential Build JDK using configure arguments]) 511207536Smav fi]) 512207536Smav EXTERNAL_BUILDJDK=true 513207536Smav else 514207536Smav if test "x$COMPILE_TYPE" = "xcross"; then 515207536Smav BUILD_JDK="\$(BUILDJDK_OUTPUTDIR)/jdk" 516207536Smav BUILD_JDK_FOUND=yes 517207536Smav CREATE_BUILDJDK=true 518207536Smav AC_MSG_CHECKING([for Build JDK]) 519207536Smav AC_MSG_RESULT([yes, will build it for the host platform]) 520207536Smav else 521207536Smav BUILD_JDK="\$(JDK_OUTPUTDIR)" 522207536Smav BUILD_JDK_FOUND=yes 523207536Smav AC_MSG_CHECKING([for Build JDK]) 524207536Smav AC_MSG_RESULT([yes, will use output dir]) 525207536Smav fi 526207536Smav fi 527207536Smav 528207536Smav JMOD="$BUILD_JDK/bin/jmod" 529207536Smav JLINK="$BUILD_JDK/bin/jlink" 530207536Smav AC_SUBST(JMOD) 531207536Smav AC_SUBST(JLINK) 532207536Smav 533207536Smav if test "x$BUILD_JDK_FOUND" != "xyes"; then 534207536Smav AC_MSG_CHECKING([for Build JDK]) 535207536Smav AC_MSG_RESULT([no]) 536207536Smav AC_MSG_ERROR([Could not find a suitable Build JDK]) 537207536Smav fi 538207536Smav 539207536Smav AC_SUBST(CREATE_BUILDJDK) 540207536Smav AC_SUBST(BUILD_JDK) 541207536Smav AC_SUBST(EXTERNAL_BUILDJDK) 542207536Smav]) 543207536Smav