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