How to pass additional options to boot jdk during configure, _JAVA_OPTIONS does not work
Magnus Ihse Bursie
magnus.ihse.bursie at oracle.com
Thu Sep 20 11:36:22 UTC 2018
On 2018-09-20 12:41, Ao Qi wrote:
> On Thu, Sep 20, 2018 at 4:10 PM Magnus Ihse Bursie
> <magnus.ihse.bursie at oracle.com> wrote:
>> On 2018-09-20 09:26, Ao Qi wrote:
>>
>> Hi,
>>
>> Is there any options or methods that I can pass additional jdk options
>> to the boot jdk when I configure jdk/jdk? I found
>> --with-boot-jdk-jvmargs, but I think it is effective during building
>> the jdk, not configuring the jdk.
>>
>> You are correct, the additional arguments in --with-boot-jdk-jvmargs is only used during the build, not during configure.
>>
>> I used _JAVA_OPTIONS, but it failed to configure (fail to detect jdk
>> version). I made a patch:
>>
>> $ hg diff
>> diff -r feb4c9e03aed make/autoconf/basics.m4
>> --- a/make/autoconf/basics.m4 Tue Sep 18 19:44:27 2018 -0700
>> +++ b/make/autoconf/basics.m4 Wed Sep 19 11:44:54 2018 +0800
>> @@ -168,7 +168,7 @@
>> [
>> $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
>> $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
>> - OUTPUT=`$3 $1 -version 2>&1`
>> + OUTPUT=`$3 $1 -version 2>&1 | $GREP -v "^Picked up _JAVA_OPTIONS:"`
>> FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
>> FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
>> if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
>> diff -r feb4c9e03aed make/autoconf/boot-jdk.m4
>> --- a/make/autoconf/boot-jdk.m4 Tue Sep 18 19:44:27 2018 -0700
>> +++ b/make/autoconf/boot-jdk.m4 Wed Sep 19 11:44:54 2018 +0800
>> @@ -74,7 +74,7 @@
>> BOOT_JDK_FOUND=no
>> else
>> # Oh, this is looking good! We probably have found a proper
>> JDK. Is it the correct version?
>> - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
>> + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 |
>> $GREP -v "^Picked up _JAVA_OPTIONS:" | $HEAD -n 1`
>>
>> # Extra M4 quote needed to protect [] in grep expression.
>> [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
>> @@ -90,7 +90,7 @@
>> AC_MSG_CHECKING([for Boot JDK])
>> AC_MSG_RESULT([$BOOT_JDK])
>> AC_MSG_CHECKING([Boot JDK version])
>> - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 |
>> $TR '\n\r' ' '`
>> + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 |
>> $GREP -v "^Picked up _JAVA_OPTIONS:" | $TR '\n\r' ' '`
>> AC_MSG_RESULT([$BOOT_JDK_VERSION])
>> fi # end check jdk version
>> fi # end check javac
>>
>>
>>
>> This works for me. The _JAVA_OPTIONS is effective during configure. Is
>> there some other way to do that (without changing the code)? Or
>> otherwise is it possible to accept this patch?
>>
>> Hm. Using _JAVA_OPTIONS is really not good. It's a very hidden way to influence the behavior of a running Java process. It might fail if it is not accepted on both the boot JDK and the newly built JDK.
>>
>> I think a better solution would be to add the --with-boot-jdk-jvmargs to the boot JDK version check.
>>
>> Here's an alternative patch. Please try it out and see if it works for you. It will apply the --with-boot-jdk-jvmargs at all calls to Java.
>>
> This patch works for me, and it passed my test script. Thanks! If this
> patch is intended to push into jdk/jdk, just one minor thing: is
> JAVA_TOOL_OPTIONS also needed to be considered?
I didn't even know there was a JAVA_TOOL_OPTIONS. :) Yes, we should
handle that as well. I'll update the patch and put it out for review.
Thanks!
/Magnus
>
> Cheers,
> Ao Qi
>
>> diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4
>> --- a/make/autoconf/basics.m4
>> +++ b/make/autoconf/basics.m4
>> @@ -168,7 +168,7 @@
>> [
>> $ECHO "Check if jvm arg is ok: $1" >&AS_MESSAGE_LOG_FD
>> $ECHO "Command: $3 $1 -version" >&AS_MESSAGE_LOG_FD
>> - OUTPUT=`$3 $1 -version 2>&1`
>> + OUTPUT=`$3 $1 $USER_BOOT_JDK_OPTIONS -version 2>&1`
>> FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
>> FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
>> if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
>> diff --git a/make/autoconf/boot-jdk.m4 b/make/autoconf/boot-jdk.m4
>> --- a/make/autoconf/boot-jdk.m4
>> +++ b/make/autoconf/boot-jdk.m4
>> @@ -74,7 +74,17 @@
>> BOOT_JDK_FOUND=no
>> else
>> # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version?
>> - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`
>> + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $HEAD -n 1`
>> + if [ [[ "$BOOT_JDK_VERSION" =~ "Picked up _JAVA_OPTIONS" ]] ]; then
>> + AC_MSG_NOTICE([You have _JAVA_OPTIONS set. This can mess up the build. Please use --with-boot-jdk-jvmargs instead.])
>> + AC_MSG_ERROR([Cannot continue])
>> + fi
>> + if [ [[ "$BOOT_JDK_VERSION" =~ "Unrecognized option" ]] ]; then
>> + AC_MSG_NOTICE([The specified --with-boot-jdk-jvmargs is invalid for the tested java])
>> + AC_MSG_NOTICE([Error message: "$BOOT_JDK_VERSION".])
>> + AC_MSG_NOTICE([Please fix arguments, or point to an explicit boot JDK which accept these arguments])
>> + AC_MSG_ERROR([Cannot continue])
>> + fi
>>
>> # Extra M4 quote needed to protect [] in grep expression.
>> [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
>> @@ -90,7 +100,7 @@
>> AC_MSG_CHECKING([for Boot JDK])
>> AC_MSG_RESULT([$BOOT_JDK])
>> AC_MSG_CHECKING([Boot JDK version])
>> - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '`
>> + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" $USER_BOOT_JDK_OPTIONS -version 2>&1 | $TR '\n\r' ' '`
>> AC_MSG_RESULT([$BOOT_JDK_VERSION])
>> fi # end check jdk version
>> fi # end check javac
>> @@ -283,6 +293,11 @@
>> AC_ARG_WITH(boot-jdk, [AS_HELP_STRING([--with-boot-jdk],
>> [path to Boot JDK (used to bootstrap build) @<:@probed@:>@])])
>>
>> + AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
>> + [specify additional arguments to be passed to Boot JDK tools @<:@none@:>@])])
>> +
>> + USER_BOOT_JDK_OPTIONS="$with_boot_jdk_jvmargs"
>> +
>> # We look for the Boot JDK through various means, going from more certain to
>> # more of a guess-work. After each test, BOOT_JDK_FOUND is set to "yes" if
>> # we detected something (if so, the path to the jdk is in BOOT_JDK). But we
>> @@ -372,10 +387,6 @@
>> # Specify jvm options for anything that is run with the Boot JDK.
>> # Not all JVM:s accept the same arguments on the command line.
>> #
>> - AC_ARG_WITH(boot-jdk-jvmargs, [AS_HELP_STRING([--with-boot-jdk-jvmargs],
>> - [specify JVM arguments to be passed to all java invocations of boot JDK, overriding the default values,
>> - e.g --with-boot-jdk-jvmargs="-Xmx8G -enableassertions"])])
>> -
>> AC_MSG_CHECKING([flags for boot jdk java command] )
>>
>> # Force en-US environment
>> @@ -389,8 +400,8 @@
>> ADD_JVM_ARG_IF_OK([-Xshare:auto],boot_jdk_jvmargs,[$JAVA])
>> fi
>>
>> - # Apply user provided options.
>> - ADD_JVM_ARG_IF_OK([$with_boot_jdk_jvmargs],boot_jdk_jvmargs,[$JAVA])
>> + # Finally append user provided options to allow them to override.
>> + ADD_JVM_ARG_IF_OK([$USER_BOOT_JDK_OPTIONS],boot_jdk_jvmargs,[$JAVA])
>>
>> AC_MSG_RESULT([$boot_jdk_jvmargs])
>>
>> /Magnus
>>
>> Cheers,
>> Ao Qi
>>
>>
More information about the build-dev
mailing list