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