annotate make/autoconf/boot-jdk.m4 @ 57834:00d9f8de0e3d

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