简体   繁体   English

如何配置 openJDK11 以从源代码构建?

[英]How to configure openJDK11 for build from sources?

I need to cross-compile from sources this OpenJava fork https://gitlab.com/gosjava/11/openjdk/-/tree/master/ - for aarch64-linux-gnu devkit target: For that I installed java 10.0.2 as host JDK then ran "./configure"我需要从源代码交叉编译这个 OpenJava fork https://gitlab.com/gosjava/11/openjdk/-/tree/master/ - 对于 aarch64-linux-gnu devkit 目标:为此我安装了 java 10.0。主机 JDK 然后运行“./configure”

└─$ ./configure    
...
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
checking for javac... /home/katya/java/bin/javac
checking for java... /home/katya/java/bin/java
configure: Found potential Boot JDK using java(c) in PATH
configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version (Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: Could not find a valid Boot JDK. You might be able to fix this by running 'sudo apt-get install openjdk-8-jdk'.
configure: This might be fixed by explicitly setting --with-boot-jdk
configure: error: Cannot continue
configure exiting with result code 1

Full log here https://gist.github.com/iva-nova-e-katerina/3061b865beb48dc25594bc360508d6a3 Could you tell me why the configure said that I use wrong JDK?完整日志在这里https://gist.github.com/iva-nova-e-katerina/3061b865beb48dc25594bc360508d6a3你能告诉我为什么配置说我使用了错误的JDK吗?

That message is being generated by the BOOTJDK_DO_CHECK autoconf macro whose definition is in "jdk11u/make/autoconf/boot-jdk.m4".该消息是由定义在“jdk11u/make/autoconf/boot-jdk.m4”中的BOOTJDK_DO_CHECK autoconf 宏生成的。 If you look at the file you will see the following:如果您查看该文件,您将看到以下内容:

      BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $HEAD -n 1`

      # Extra M4 quote needed to protect [] in grep expression.
      [FOUND_CORRECT_VERSION=`$ECHO $BOOT_JDK_VERSION \
          | $EGREP "\"(${DEFAULT_ACCEPTABLE_BOOT_VERSIONS// /|})([\.+-].*)?\""`]
      if test "x$FOUND_CORRECT_VERSION" = x; then
        AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect
                       JDK version ($BOOT_JDK_VERSION); ignoring])
        AC_MSG_NOTICE([(Your Boot JDK version must be one of:
                       $DEFAULT_ACCEPTABLE_BOOT_VERSIONS)])
        BOOT_JDK_FOUND=no

(I've added a couple of line breaks for readability...) (为了便于阅读,我添加了几个换行符......)

If we compare this to the actual error message:如果我们将其与实际的错误消息进行比较:

configure: Potential Boot JDK found at /home/katya/java is incorrect JDK version 
(Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true); 
ignoring

So... it looks like:所以......它看起来像:

  1. You have (or something has) set the _JAVA_OPTIONS environment variable in the environment that is in effect when you run configure .您已经(或某些东西)在运行configure时有效的环境中设置了_JAVA_OPTIONS环境变量。
  2. The java command is warning you that _JAVA_OPTIONS are in effect (for security reasons.). java命令警告您_JAVA_OPTIONS有效(出于安全原因。)。 Presumably the real version string gets output as the next line大概是真正的版本字符串得到 output 作为下一行
  3. The macro captures just the first line ( head -n 1 )... and then uses the warning message as if it was the real version string.该宏仅捕获第一行( head -n 1 )...然后使用警告消息,就好像它是真正的版本字符串一样。
  4. This bogus version causes the Boot Java version checking logic to fail.此伪造版本导致 Boot Java 版本检查逻辑失败。

You probably have a valid Boot JDK... but configure has been confused by the warning message, and thinks that you don't.您可能有一个有效的 Boot JDK……但是configure被警告消息弄糊涂了,并认为您没有。

Possible solutions:可能的解决方案:

  • Just unset _JAVA_OPTIONS .只需取消设置_JAVA_OPTIONS Those options don't look relevant to what you are doing.这些选项看起来与您正在做的事情无关。

  • If the are relevant to building, unset _JAVA_OPTIONS while you run configure .如果与构建相关,请在运行configure时取消设置_JAVA_OPTIONS Then set it again.然后重新设置。

  • If there is some reason why unsetting _JAVA_OPTIONS won't work, you could modify the above ".m4" file to skip the version check.如果由于某些原因_JAVA_OPTIONS不起作用,您可以修改上述“.m4”文件以跳过版本检查。 (Ughhh...) (呃……)


You can read more about this unwanted (though actually necessary) behavior of _JAVA_OPTIONS in:您可以阅读更多关于_JAVA_OPTIONS的这种不需要的(尽管实际上是必要的)行为:

(And the short answer is "you can't"... apart from unsetting the environment variable.) (简短的回答是“你不能”......除了取消设置环境变量。)

install OpenJDK binaries at, say /opt/jdk-bin Then,安装 OpenJDK 二进制文件,例如 /opt/jdk-bin 然后,

./configure --with-boot-jdk=/opt/jdk ./configure --with-boot-jdk=/opt/jdk

and that's it就是这样

Well, I am building Linux systems by checking my ideas.好吧,我正在通过检查我的想法来构建 Linux 系统。 So it is not about feelings.所以这与感情无关。 It is about checking and rechecking them.这是关于检查和重新检查它们。 That's the only way to learn.这是学习的唯一途径。 Anyhow, building OpenJDK is nontrivial and requires some work.无论如何,构建 OpenJDK 并非易事,需要一些工作。 So所以

build/.configure-support/generated-configure.sh... You have JAVA_OPTIONS or JAVA_TOOL_OPTIONS set. build/.configure-support/generated-configure.sh ...您设置了 JAVA_OPTIONS 或 JAVA_TOOL_OPTIONS。 This can mess up the build这可能会破坏构建

is irrelevant to Catherine's question.与凯瑟琳的问题无关。

configure: This might be fixed by explicitly setting --with-boot-jdk配置:这可以通过显式设置 --with-boot-jdk 来解决

happened to me, so I found the above solution.发生在我身上,所以我找到了上述解决方案。 It did solve the problem and the build went through.它确实解决了问题并且构建通过了。 Alas, as Linux has its own mysterious ways, this mornging I rechecked and surprisingly configure went through smoothly but the build failed on account warrnings being treated as errors.唉,由于 Linux 有其自己的神秘方式,今天早上我重新检查并令人惊讶地配置顺利通过,但由于帐户警告被视为错误而构建失败。 This is resolved by这通过以下方式解决

vi build/linux-x86_64-server-release/spec.gmk vi build/linux-x86_64-server-release/spec.gmk

and deleting the occurences of -Werror in there and everything went through just fine.并删除那里出现的 -Werror ,一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM