1# 2# Copyright (c) 2011, 2021, 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# This file handles detection of the Boot JDK. The Boot JDK detection 28# process has been developed as a response to solve a complex real-world 29# problem. Initially, it was simple, but it has grown as platform after 30# platform, idiosyncracy after idiosyncracy has been supported. 31# 32# The basic idea is this: 33# 1) You need an acceptable *) JDK to use as a Boot JDK 34# 2) There are several ways to locate a JDK, that are mostly platform 35# dependent **) 36# 3) You can have multiple JDKs installed 37# 4) If possible, configure should try to dig out an acceptable JDK 38# automatically, without having to resort to command-line options 39# 40# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with 41# javac) and not a JRE, etc. 42# 43# **) On Windows we typically use a well-known path. 44# On MacOSX we typically use the tool java_home. 45# On Linux we typically find javac in the $PATH, and then follow a 46# chain of symlinks that often ends up in a real JDK. 47# 48# This leads to the code where we check in different ways to locate a 49# JDK, and if one is found, check if it is acceptable. If not, we print 50# our reasons for rejecting it (useful when debugging non-working 51# configure situations) and continue checking the next one. 52######################################################################## 53 54# Execute the check given as argument, and verify the result 55# If the Boot JDK was previously found, do nothing 56# $1 A command line (typically autoconf macro) to execute 57AC_DEFUN([BOOTJDK_DO_CHECK], 58[ 59 if test "x$BOOT_JDK_FOUND" = xno; then 60 # Now execute the test 61 $1 62 63 # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 64 if test "x$BOOT_JDK_FOUND" = xmaybe; then 65 # Do we have a bin/java? 66 if test ! -x "$BOOT_JDK/bin/java" && test ! -x "$BOOT_JDK/bin/java.exe"; then 67 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring]) 68 BOOT_JDK_FOUND=no 69 else 70 # Do we have a bin/javac? 71 if test ! -x "$BOOT_JDK/bin/javac" && test ! -x "$BOOT_JDK/bin/javac.exe"; then 72 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring]) 73 AC_MSG_NOTICE([(This might be an JRE instead of an JDK)]) 74 BOOT_JDK_FOUND=no 75 else 76 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 77 java_to_test="$BOOT_JDK/bin/java" 78 UTIL_FIXUP_EXECUTABLE(java_to_test) 79 BOOT_JDK_VERSION_OUTPUT=`$java_to_test $USER_BOOT_JDK_OPTIONS -version 2>&1` 80 # Additional [] needed to keep m4 from mangling shell constructs. 81 [ BOOT_JDK_VERSION=`echo $BOOT_JDK_VERSION_OUTPUT | $AWK '/version "[0-9a-zA-Z\._\-]+"/ {print $ 0; exit;}'` ] 82 83 if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up" ]] ]; then 84 AC_MSG_NOTICE([You have _JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.]) 85 AC_MSG_NOTICE([Java reports: "$BOOT_JDK_VERSION".]) 86 AC_MSG_ERROR([Cannot continue]) 87 fi 88 if [ [[ "$BOOT_JDK_VERSION" =~ "Unrecognized option" ]] ]; then 89 AC_MSG_NOTICE([The specified --with-boot-jdk-jvmargs is invalid for the tested java]) 90 AC_MSG_NOTICE([Error message: "$BOOT_JDK_VERSION".]) 91 AC_MSG_NOTICE([Please fix arguments, or point to an explicit boot JDK which accept these arguments]) 92 AC_MSG_ERROR([Cannot continue]) 93 fi 94 95 # Extra M4 quote needed to protect [] in grep expression. 96 [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \ 97 | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`] 98 99 if test "x$BOOT_JDK_VERSION" = x; then 100 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is not a working JDK; ignoring]) 101 AC_MSG_NOTICE([Output from java -version was: $BOOT_JDK_VERSION_OUTPUT]) 102 BOOT_JDK_FOUND=no 103 elif test "x$FOUND_CORRECT_VERSION" = x; then 104 AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) 105 AC_MSG_NOTICE([(Your Boot JDK version must be one of: $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)]) 106 BOOT_JDK_FOUND=no 107 else 108 # We're done! :-) 109 BOOT_JDK_FOUND=yes 110 UTIL_FIXUP_PATH(BOOT_JDK) 111 AC_MSG_CHECKING([for Boot JDK]) 112 AC_MSG_RESULT([$BOOT_JDK]) 113 AC_MSG_CHECKING([Boot JDK version]) 114 BOOT_JDK_VERSION=`$java_to_test $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR -d '\r'` 115 # This is not a no-op; it will portably convert newline to space 116 BOOT_JDK_VERSION=`$ECHO $BOOT_JDK_VERSION` 117 AC_MSG_RESULT([$BOOT_JDK_VERSION]) 118 fi # end check jdk version 119 fi # end check javac 120 fi # end check java 121 fi # end check boot jdk found 122 fi 123]) 124 125# Test: Is bootjdk explicitly set by command line arguments? 126AC_DEFUN([BOOTJDK_CHECK_ARGUMENTS], 127[ 128 if test "x$with_boot_jdk" != x; then 129 if test -d "$with_boot_jdk"; then 130 BOOT_JDK=$with_boot_jdk 131 BOOT_JDK_FOUND=maybe 132 elif test -f "$with_boot_jdk"; then 133 case "$with_boot_jdk" in 134 *.tar.gz ) 135 BOOT_JDK_SUPPORT_DIR=$CONFIGURESUPPORT_OUTPUTDIR/boot-jdk 136 $RM -rf $BOOT_JDK_SUPPORT_DIR 137 $MKDIR -p $BOOT_JDK_SUPPORT_DIR 138 $GUNZIP -c $with_boot_jdk | $TAR xf - -C $BOOT_JDK_SUPPORT_DIR 139 140 # Try to find javac to determine BOOT_JDK path 141 BOOT_JDK_JAVAC_PATH=`$FIND $BOOT_JDK_SUPPORT_DIR | $GREP "/bin/javac"` 142 if test "x$BOOT_JDK_JAVAC_PATH" != x; then 143 BOOT_JDK_FOUND=maybe 144 BOOT_JDK=$($DIRNAME $($DIRNAME $BOOT_JDK_JAVAC_PATH)) 145 else 146 BOOT_JDK_FOUND=no 147 fi 148 ;; 149 * ) 150 BOOT_JDK_FOUND=no 151 ;; 152 esac 153 else 154 BOOT_JDK_FOUND=no 155 fi 156 AC_MSG_NOTICE([Found potential Boot JDK using configure arguments]) 157 fi 158]) 159 160# Test: Is $JAVA_HOME set? 161AC_DEFUN([BOOTJDK_CHECK_JAVA_HOME], 162[ 163 if test "x$JAVA_HOME" != x; then 164 JAVA_HOME_PROCESSED="$JAVA_HOME" 165 UTIL_FIXUP_PATH(JAVA_HOME_PROCESSED, NOFAIL) 166 if test "x$JAVA_HOME_PROCESSED" = x || test ! -d "$JAVA_HOME_PROCESSED"; then 167 AC_MSG_NOTICE([Your JAVA_HOME points to a non-existing directory!]) 168 else 169 # Aha, the user has set a JAVA_HOME 170 # let us use that as the Boot JDK. 171 BOOT_JDK="$JAVA_HOME_PROCESSED" 172 BOOT_JDK_FOUND=maybe 173 AC_MSG_NOTICE([Found potential Boot JDK using JAVA_HOME]) 174 fi 175 fi 176]) 177 178# Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 179AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], 180[ 181 UTIL_LOOKUP_PROGS(JAVAC_CHECK, javac, , NOFIXPATH) 182 UTIL_LOOKUP_PROGS(JAVA_CHECK, java, , NOFIXPATH) 183 BINARY="$JAVAC_CHECK" 184 if test "x$JAVAC_CHECK" = x; then 185 BINARY="$JAVA_CHECK" 186 fi 187 if test "x$BINARY" != x; then 188 # So there is a java(c) binary, it might be part of a JDK. 189 # Lets find the JDK/JRE directory by following symbolic links. 190 # Linux/GNU systems often have links from /usr/bin/java to 191 # /etc/alternatives/java to the real JDK binary. 192 UTIL_REMOVE_SYMBOLIC_LINKS(BINARY) 193 BOOT_JDK=`dirname "$BINARY"` 194 BOOT_JDK=`cd "$BOOT_JDK/.."; pwd` 195 if test -x "$BOOT_JDK/bin/javac" && test -x "$BOOT_JDK/bin/java"; then 196 # Looks like we found ourselves an JDK 197 BOOT_JDK_FOUND=maybe 198 AC_MSG_NOTICE([Found potential Boot JDK using java(c) in PATH]) 199 fi 200 fi 201]) 202 203# Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) 204# $1: Argument to the java_home binary (optional) 205AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], 206[ 207 if test -x /usr/libexec/java_home; then 208 BOOT_JDK=`/usr/libexec/java_home $1` 209 BOOT_JDK_FOUND=maybe 210 AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1]) 211 fi 212]) 213 214# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 215AC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR], 216[ 217 if test "x$OPENJDK_TARGET_OS" = xmacosx; then 218 # First check at user selected default 219 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()]) 220 # If that did not work out (e.g. too old), try explicit versions instead 221 for ver in $DEFAULT_ACCEPTABLE_BOOT_VERSIONS ; do 222 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v $ver])]) 223 done 224 fi 225]) 226 227# Look for a jdk in the given path. If there are multiple, try to select the newest. 228# If found, set BOOT_JDK and BOOT_JDK_FOUND. 229# $1 = Path to directory containing jdk installations. 230# $2 = String to append to the found JDK directory to get the proper JDK home 231AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY], 232[ 233 BOOT_JDK_PREFIX="$1" 234 BOOT_JDK_SUFFIX="$2" 235 ALL_JDKS_FOUND=`$LS "$BOOT_JDK_PREFIX" 2> /dev/null | $SORT -r` 236 if test "x$ALL_JDKS_FOUND" != x; then 237 for JDK_TO_TRY in $ALL_JDKS_FOUND ; do 238 BOOTJDK_DO_CHECK([ 239 BOOT_JDK="${BOOT_JDK_PREFIX}/${JDK_TO_TRY}${BOOT_JDK_SUFFIX}" 240 if test -d "$BOOT_JDK"; then 241 BOOT_JDK_FOUND=maybe 242 AC_MSG_NOTICE([Found potential Boot JDK using well-known locations (in $BOOT_JDK_PREFIX/$JDK_TO_TRY)]) 243 fi 244 ]) 245 done 246 fi 247]) 248 249# Call BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY, but use the given 250# environmental variable as base for where to look. 251# $1 Name of an environmal variable, assumed to point to the Program Files directory. 252AC_DEFUN([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY], 253[ 254 if test "x[$]$1" != x; then 255 VIRTUAL_DIR="[$]$1/Java" 256 UTIL_FIXUP_PATH(VIRTUAL_DIR, NOFAIL) 257 if test "x$VIRTUAL_DIR" != x; then 258 BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY($VIRTUAL_DIR) 259 fi 260 fi 261]) 262 263# Test: Is there a JDK installed in default, well-known locations? 264AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], 265[ 266 if test "x$OPENJDK_TARGET_OS" = xwindows; then 267 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramW6432])]) 268 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMW6432])]) 269 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([PROGRAMFILES])]) 270 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_WINDOWS_VIRTUAL_DIRECTORY([ProgramFiles])]) 271 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/cygdrive/c/Program Files/Java])]) 272 elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 273 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 274 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/System/Library/Java/JavaVirtualMachines],[/Contents/Home])]) 275 elif test "x$OPENJDK_TARGET_OS" = xlinux; then 276 BOOTJDK_DO_CHECK([BOOTJDK_FIND_BEST_JDK_IN_DIRECTORY([/usr/lib/jvm])]) 277 fi 278]) 279 280# Check that a command-line tool in the Boot JDK is correct 281# $1 = name of variable to assign 282# $2 = name of binary 283AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], 284[ 285 # Use user overridden value if available, otherwise locate tool in the Boot JDK. 286 UTIL_REQUIRE_SPECIAL($1, 287 [ 288 AC_MSG_CHECKING([for $2 [[Boot JDK]]]) 289 $1=$BOOT_JDK/bin/$2 290 if test ! -x [$]$1 && test ! -x [$]$1.exe; then 291 AC_MSG_RESULT(not found) 292 AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitly setting --with-boot-jdk]) 293 AC_MSG_ERROR([Could not find $2 in the Boot JDK]) 294 fi 295 AC_MSG_RESULT(\[$]BOOT_JDK/bin/$2) 296 UTIL_FIXUP_EXECUTABLE($1) 297 AC_SUBST($1) 298 ]) 299]) 300 301############################################################################### 302# 303# We need a Boot JDK to bootstrap the build. 304# 305 306AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], 307[ 308 BOOT_JDK_FOUND=no 309 AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk], 310 [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])]) 311 312 AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs], 313 [specify additional arguments to be passed to Boot JDK tools @<:@none@:>@])]) 314 315 USER_BOOT_JDK_OPTIONS="$with_boot_jdk_jvmargs" 316 317 # We look for the Boot JDK through various means, going from more certain to 318 # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if 319 # we detected something (if so, the path to the jdk is in BOOT_JDK). But we 320 # must check if this is indeed valid; otherwise we'll continue looking. 321 322 # Test: Is bootjdk explicitly set by command line arguments? 323 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_ARGUMENTS]) 324 if test "x$with_boot_jdk" != x && test "x$BOOT_JDK_FOUND" = xno; then 325 # Having specified an argument which is incorrect will produce an instant failure; 326 # we should not go on looking 327 AC_MSG_ERROR([The path given by --with-boot-jdk does not contain a valid Boot JDK]) 328 fi 329 330 # Test: Is $JAVA_HOME set? 331 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) 332 333 # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? 334 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR]) 335 336 # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? 337 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) 338 339 # Test: Is there a JDK installed in default, well-known locations? 340 BOOTJDK_DO_CHECK([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS]) 341 342 # If we haven't found anything yet, we've truly lost. Give up. 343 if test "x$BOOT_JDK_FOUND" = xno; then 344 HELP_MSG_MISSING_DEPENDENCY([openjdk]) 345 AC_MSG_NOTICE([Could not find a valid Boot JDK. $HELP_MSG]) 346 AC_MSG_NOTICE([This might be fixed by explicitly setting --with-boot-jdk]) 347 AC_MSG_ERROR([Cannot continue]) 348 fi 349 350 AC_SUBST(BOOT_JDK) 351 352 # Setup tools from the Boot JDK. 353 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) 354 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) 355 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVADOC, javadoc) 356 BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) 357 358 # Finally, set some other options... 359 360 # When compiling code to be executed by the Boot JDK, force compatibility with the 361 # oldest supported bootjdk. 362 OLDEST_BOOT_JDK=`$ECHO $DEFAULT_ACCEPTABLE_BOOT_VERSIONS \ 363 | $TR " " "\n" | $SORT -n | $HEAD -n1` 364 # -Xlint:-options is added to avoid "warning: [options] system modules path not set in conjunction with -source" 365 BOOT_JDK_SOURCETARGET="-source $OLDEST_BOOT_JDK -target $OLDEST_BOOT_JDK -Xlint:-options" 366 AC_SUBST(BOOT_JDK_SOURCETARGET) 367 368 # Check if the boot jdk is 32 or 64 bit 369 if $JAVA -version 2>&1 | $GREP -q "64-Bit"; then 370 BOOT_JDK_BITS="64" 371 else 372 BOOT_JDK_BITS="32" 373 fi 374 AC_MSG_CHECKING([if Boot JDK is 32 or 64 bits]) 375 AC_MSG_RESULT([$BOOT_JDK_BITS]) 376 377 # Try to enable CDS 378 AC_MSG_CHECKING([for local Boot JDK Class Data Sharing (CDS)]) 379 BOOT_JDK_CDS_ARCHIVE=$CONFIGURESUPPORT_OUTPUTDIR/classes.jsa 380 UTIL_ADD_JVM_ARG_IF_OK([-XX:+UnlockDiagnosticVMOptions -XX:-VerifySharedSpaces -XX:SharedArchiveFile=$BOOT_JDK_CDS_ARCHIVE],boot_jdk_cds_args,[$JAVA]) 381 382 if test "x$boot_jdk_cds_args" != x; then 383 # Try creating a CDS archive 384 $JAVA $boot_jdk_cds_args -Xshare:dump > /dev/null 2>&1 385 if test $? -eq 0; then 386 BOOTJDK_USE_LOCAL_CDS=true 387 AC_MSG_RESULT([yes, created]) 388 else 389 # Generation failed, don't use CDS. 390 BOOTJDK_USE_LOCAL_CDS=false 391 AC_MSG_RESULT([no, creation failed]) 392 fi 393 else 394 BOOTJDK_USE_LOCAL_CDS=false 395 AC_MSG_RESULT([no, -XX:SharedArchiveFile not supported]) 396 fi 397]) 398 399AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK_ARGUMENTS], 400[ 401 ############################################################################## 402 # 403 # Specify jvm options for anything that is run with the Boot JDK. 404 # Not all JVM:s accept the same arguments on the command line. 405 # 406 AC_MSG_CHECKING([flags for boot jdk java command] ) 407 408 # Force en-US environment 409 UTIL_ADD_JVM_ARG_IF_OK([-Duser.language=en -Duser.country=US],boot_jdk_jvmargs,[$JAVA]) 410 411 if test "x$BOOTJDK_USE_LOCAL_CDS" = xtrue; then 412 # Use our own CDS archive 413 UTIL_ADD_JVM_ARG_IF_OK([$boot_jdk_cds_args -Xshare:auto],boot_jdk_jvmargs,[$JAVA]) 414 else 415 # Otherwise optimistically use the system-wide one, if one is present 416 UTIL_ADD_JVM_ARG_IF_OK([-Xshare:auto],boot_jdk_jvmargs,[$JAVA]) 417 fi 418 419 # Finally append user provided options to allow them to override. 420 UTIL_ADD_JVM_ARG_IF_OK([$USER_BOOT_JDK_OPTIONS],boot_jdk_jvmargs,[$JAVA]) 421 422 AC_MSG_RESULT([$boot_jdk_jvmargs]) 423 424 # For now, general JAVA_FLAGS are the same as the boot jdk jvmargs 425 JAVA_FLAGS=$boot_jdk_jvmargs 426 AC_SUBST(JAVA_FLAGS) 427 428 AC_MSG_CHECKING([flags for boot jdk java command for big workloads]) 429 430 # Starting amount of heap memory. 431 UTIL_ADD_JVM_ARG_IF_OK([-Xms64M],boot_jdk_jvmargs_big,[$JAVA]) 432 BOOTCYCLE_JVM_ARGS_BIG=-Xms64M 433 434 # Maximum amount of heap memory. 435 JVM_HEAP_LIMIT_32="768" 436 # Running a 64 bit JVM allows for and requires a bigger heap 437 JVM_HEAP_LIMIT_64="1600" 438 JVM_HEAP_LIMIT_GLOBAL=`expr $MEMORY_SIZE / 2` 439 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_32"; then 440 JVM_HEAP_LIMIT_32=$JVM_HEAP_LIMIT_GLOBAL 441 fi 442 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "$JVM_HEAP_LIMIT_64"; then 443 JVM_HEAP_LIMIT_64=$JVM_HEAP_LIMIT_GLOBAL 444 fi 445 if test "$JVM_HEAP_LIMIT_GLOBAL" -lt "512"; then 446 JVM_HEAP_LIMIT_32=512 447 JVM_HEAP_LIMIT_64=512 448 fi 449 450 if test "x$BOOT_JDK_BITS" = "x32"; then 451 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_32 452 else 453 JVM_MAX_HEAP=$JVM_HEAP_LIMIT_64 454 fi 455 UTIL_ADD_JVM_ARG_IF_OK([-Xmx${JVM_MAX_HEAP}M],boot_jdk_jvmargs_big,[$JAVA]) 456 457 AC_MSG_RESULT([$boot_jdk_jvmargs_big]) 458 459 JAVA_FLAGS_BIG=$boot_jdk_jvmargs_big 460 AC_SUBST(JAVA_FLAGS_BIG) 461 462 if test "x$OPENJDK_TARGET_CPU_BITS" = "x32"; then 463 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_32 464 else 465 BOOTCYCLE_MAX_HEAP=$JVM_HEAP_LIMIT_64 466 fi 467 BOOTCYCLE_JVM_ARGS_BIG="$BOOTCYCLE_JVM_ARGS_BIG -Xmx${BOOTCYCLE_MAX_HEAP}M" 468 AC_MSG_CHECKING([flags for bootcycle boot jdk java command for big workloads]) 469 AC_MSG_RESULT([$BOOTCYCLE_JVM_ARGS_BIG]) 470 AC_SUBST(BOOTCYCLE_JVM_ARGS_BIG) 471 472 AC_MSG_CHECKING([flags for boot jdk java command for small workloads]) 473 474 # Use serial gc for small short lived tools if possible 475 UTIL_ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA]) 476 UTIL_ADD_JVM_ARG_IF_OK([-Xms32M],boot_jdk_jvmargs_small,[$JAVA]) 477 UTIL_ADD_JVM_ARG_IF_OK([-Xmx512M],boot_jdk_jvmargs_small,[$JAVA]) 478 UTIL_ADD_JVM_ARG_IF_OK([-XX:TieredStopAtLevel=1],boot_jdk_jvmargs_small,[$JAVA]) 479 480 AC_MSG_RESULT([$boot_jdk_jvmargs_small]) 481 482 JAVA_FLAGS_SMALL=$boot_jdk_jvmargs_small 483 AC_SUBST(JAVA_FLAGS_SMALL) 484 485 # Don't presuppose SerialGC is present in the buildjdk. Also, we cannot test 486 # the buildjdk, but on the other hand we know what it will support. 487 BUILDJDK_JAVA_FLAGS_SMALL="-Xms32M -Xmx512M -XX:TieredStopAtLevel=1" 488 AC_SUBST(BUILDJDK_JAVA_FLAGS_SMALL) 489 490 JAVA_TOOL_FLAGS_SMALL="" 491 for f in $JAVA_FLAGS_SMALL; do 492 JAVA_TOOL_FLAGS_SMALL="$JAVA_TOOL_FLAGS_SMALL -J$f" 493 done 494 AC_SUBST(JAVA_TOOL_FLAGS_SMALL) 495]) 496 497# BUILD_JDK: the location of the latest JDK that can run 498# on the host system and supports the target class file version 499# generated in this JDK build. This variable should only be 500# used after the launchers are built. 501# 502 503# Execute the check given as argument, and verify the result. 504# If the JDK was previously found, do nothing. 505# $1 A command line (typically autoconf macro) to execute 506AC_DEFUN([BOOTJDK_CHECK_BUILD_JDK], 507[ 508 if test "x$BUILD_JDK_FOUND" = xno; then 509 # Execute the test 510 $1 511 512 # If previous step claimed to have found a JDK, check it to see if it seems to be valid. 513 if test "x$BUILD_JDK_FOUND" = xmaybe; then 514 # Do we have a bin/java? 515 if test ! -x "$BUILD_JDK/bin/java"; then 516 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/java; ignoring]) 517 BUILD_JDK_FOUND=no 518 elif test ! -x "$BUILD_JDK/bin/jlink"; then 519 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jlink; ignoring]) 520 BUILD_JDK_FOUND=no 521 elif test ! -x "$BUILD_JDK/bin/jmod"; then 522 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/jmod; ignoring]) 523 BUILD_JDK_FOUND=no 524 elif test ! -x "$BUILD_JDK/bin/javac"; then 525 # Do we have a bin/javac? 526 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK did not contain bin/javac; ignoring]) 527 AC_MSG_NOTICE([(This might be a JRE instead of an JDK)]) 528 BUILD_JDK_FOUND=no 529 else 530 # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? 531 # Additional [] needed to keep m4 from mangling shell constructs. 532 [ BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $AWK '/version "[0-9a-zA-Z\._\-]+"/ {print $ 0; exit;}'` ] 533 534 # Extra M4 quote needed to protect [] in grep expression. 535 [FOUND_CORRECT_VERSION=`echo $BUILD_JDK_VERSION | $EGREP "\"$VERSION_FEATURE([\.+-].*)?\""`] 536 if test "x$FOUND_CORRECT_VERSION" = x; then 537 AC_MSG_NOTICE([Potential Build JDK found at $BUILD_JDK is incorrect JDK version ($BUILD_JDK_VERSION); ignoring]) 538 AC_MSG_NOTICE([(Your Build JDK must be version $VERSION_FEATURE)]) 539 BUILD_JDK_FOUND=no 540 else 541 # We're done! 542 BUILD_JDK_FOUND=yes 543 UTIL_FIXUP_PATH(BUILD_JDK) 544 AC_MSG_CHECKING([for Build JDK]) 545 AC_MSG_RESULT([$BUILD_JDK]) 546 AC_MSG_CHECKING([Build JDK version]) 547 BUILD_JDK_VERSION=`"$BUILD_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` 548 AC_MSG_RESULT([$BUILD_JDK_VERSION]) 549 fi # end check jdk version 550 fi # end check java 551 fi # end check build jdk found 552 fi 553]) 554 555# By default the BUILD_JDK is the JDK_OUTPUTDIR. If the target architecture 556# is different than the host system doing the build (e.g. cross-compilation), 557# a special BUILD_JDK is built as part of the build process. An external 558# prebuilt BUILD_JDK can also be supplied. 559AC_DEFUN([BOOTJDK_SETUP_BUILD_JDK], 560[ 561 AC_ARG_WITH(build-jdk, [AS_HELP_STRING([--with-build-jdk], 562 [path to JDK of same version as is being built@<:@the newly built JDK@:>@])]) 563 564 CREATE_BUILDJDK=false 565 EXTERNAL_BUILDJDK=false 566 BUILD_JDK_FOUND="no" 567 if test "x$with_build_jdk" != "x"; then 568 BOOTJDK_CHECK_BUILD_JDK([ 569 if test "x$with_build_jdk" != x; then 570 BUILD_JDK=$with_build_jdk 571 BUILD_JDK_FOUND=maybe 572 AC_MSG_NOTICE([Found potential Build JDK using configure arguments]) 573 fi]) 574 EXTERNAL_BUILDJDK=true 575 else 576 if test "x$COMPILE_TYPE" = "xcross"; then 577 BUILD_JDK="\$(BUILDJDK_OUTPUTDIR)/jdk" 578 BUILD_JDK_FOUND=yes 579 CREATE_BUILDJDK=true 580 AC_MSG_CHECKING([for Build JDK]) 581 AC_MSG_RESULT([yes, will build it for the host platform]) 582 else 583 BUILD_JDK="\$(JDK_OUTPUTDIR)" 584 BUILD_JDK_FOUND=yes 585 AC_MSG_CHECKING([for Build JDK]) 586 AC_MSG_RESULT([yes, will use output dir]) 587 fi 588 fi 589 590 # Since these tools do not yet exist, we cannot use UTIL_FIXUP_EXECUTABLE to 591 # detect the need of fixpath 592 JMOD="$BUILD_JDK/bin/jmod" 593 UTIL_ADD_FIXPATH(JMOD) 594 JLINK="$BUILD_JDK/bin/jlink" 595 UTIL_ADD_FIXPATH(JLINK) 596 AC_SUBST(JMOD) 597 AC_SUBST(JLINK) 598 599 if test "x$BUILD_JDK_FOUND" != "xyes"; then 600 AC_MSG_CHECKING([for Build JDK]) 601 AC_MSG_RESULT([no]) 602 AC_MSG_ERROR([Could not find a suitable Build JDK]) 603 fi 604 605 AC_SUBST(CREATE_BUILDJDK) 606 AC_SUBST(BUILD_JDK) 607 AC_SUBST(EXTERNAL_BUILDJDK) 608]) 609 610# The docs-reference JDK is used to run javadoc for the docs-reference targets. 611# If not set, the reference docs will be built using the interim javadoc. 612AC_DEFUN([BOOTJDK_SETUP_DOCS_REFERENCE_JDK], 613[ 614 AC_ARG_WITH(docs-reference-jdk, [AS_HELP_STRING([--with-docs-reference-jdk], 615 [path to JDK to use for building the reference documentation])]) 616 617 AC_MSG_CHECKING([for docs-reference JDK]) 618 if test "x$with_docs_reference_jdk" != "x"; then 619 DOCS_REFERENCE_JDK="$with_docs_reference_jdk" 620 AC_MSG_RESULT([$DOCS_REFERENCE_JDK]) 621 DOCS_REFERENCE_JAVADOC="$DOCS_REFERENCE_JDK/bin/javadoc" 622 if test ! -x "$DOCS_REFERENCE_JAVADOC"; then 623 AC_MSG_ERROR([docs-reference JDK found at $DOCS_REFERENCE_JDK did not contain bin/javadoc]) 624 fi 625 UTIL_FIXUP_EXECUTABLE(DOCS_REFERENCE_JAVADOC) 626 else 627 AC_MSG_RESULT([no, using interim javadoc for the docs-reference targets]) 628 # By leaving this empty, Docs.gmk will revert to the default interim javadoc 629 DOCS_REFERENCE_JAVADOC= 630 fi 631 632 AC_SUBST(DOCS_REFERENCE_JAVADOC) 633]) 634