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