在 CentOS5 中构建 OpenJDK 9
Build OpenJDK 9 in CentOS5
我试图在 Centos 5 中构建 OpenJDK 9。我使用了
sh ./configure --disable-warnings-as-errors
make all
我收到以下错误。
Building target 'all' in configuration 'linux-x86_64-normal-server-release'
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
/usr/bin/objcopy: '/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so': No such file
gmake[3]: *** [/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so] Error 1
gmake[2]: *** [java.base-libs] Error 2
ERROR: Build failed for target 'all' in configuration 'linux-x86_64-normal-
server-release' (exit code 2)
=== Output from failing command(s) repeated here ===
* For target support_native_java.base_libjava_BUILD_LIBJAVA_link:
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
* All command lines available in /root/jdk9/build/linux-x86_64-normal-
server-release/make-support/failure-logs.
=== End of repeated output ===
No indication of failed target found.
Hint: Try searching the build log for '] Error'.
Hint: See common/doc/building.html#troubleshooting for assistance.
make[1]: *** [main] Error 2
make: *** [all] Error 2
我也尝试了其他的 make target,比如 make images 和 make install。但仍然出现相同的错误。我的 GCC 版本是 gcc (GCC) 4.4.7,我手动安装的,因为 Centos 5 默认有一个旧版本。
构建 JDK 至少需要 GCC 5.0(参见 Building the JDK: CC)。
这似乎是 glibc 版本的问题(参见 redhat-issue, util-linux)。因此,将您的 glibc 更新到最新版本可能会解决它。
如果您不想更新系统的 glibc,这里有另一种选择:
通过查看 fallocate, we find that the description mentions that posix_fallocate(3) 的手册页,它是一个可移植的、POSIX.1 指定的版本,以防 mode
参数具有默认值 (0) . fallocate64
也是如此。
由于上述错误的所有出现都已使用默认 mode
值,您可以将它们替换为 posix_fallocate64()
(而不是像您在另一条评论中提到的那样将它们注释掉)。
指示的手册页说:
This default behavior [of fallocate
with mode
=0] closely resembles the
behavior of the posix_fallocate(3) library function, and is intended
as a method of optimally implementing that function.
我试图在 Centos 5 中构建 OpenJDK 9。我使用了
sh ./configure --disable-warnings-as-errors
make all
我收到以下错误。
Building target 'all' in configuration 'linux-x86_64-normal-server-release'
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
/usr/bin/objcopy: '/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so': No such file
gmake[3]: *** [/root/jdk9/build/linux-x86_64-normal-server-
release/support/modules_libs/java.base/libjava.so] Error 1
gmake[2]: *** [java.base-libs] Error 2
ERROR: Build failed for target 'all' in configuration 'linux-x86_64-normal-
server-release' (exit code 2)
=== Output from failing command(s) repeated here ===
* For target support_native_java.base_libjava_BUILD_LIBJAVA_link:
/root/jdk9/build/linux-x86_64-normal-server-
release/support/native/java.base/libjava/io_util_md.o: In function
`handleSetLength':
/root/jdk9/jdk/src/java.base/unix/native/libjava/io_util_md.c:228:
undefined reference to `fallocate64'
collect2: ld returned 1 exit status
* All command lines available in /root/jdk9/build/linux-x86_64-normal-
server-release/make-support/failure-logs.
=== End of repeated output ===
No indication of failed target found.
Hint: Try searching the build log for '] Error'.
Hint: See common/doc/building.html#troubleshooting for assistance.
make[1]: *** [main] Error 2
make: *** [all] Error 2
我也尝试了其他的 make target,比如 make images 和 make install。但仍然出现相同的错误。我的 GCC 版本是 gcc (GCC) 4.4.7,我手动安装的,因为 Centos 5 默认有一个旧版本。
构建 JDK 至少需要 GCC 5.0(参见 Building the JDK: CC)。
这似乎是 glibc 版本的问题(参见 redhat-issue, util-linux)。因此,将您的 glibc 更新到最新版本可能会解决它。
如果您不想更新系统的 glibc,这里有另一种选择:
通过查看 fallocate, we find that the description mentions that posix_fallocate(3) 的手册页,它是一个可移植的、POSIX.1 指定的版本,以防 mode
参数具有默认值 (0) . fallocate64
也是如此。
由于上述错误的所有出现都已使用默认 mode
值,您可以将它们替换为 posix_fallocate64()
(而不是像您在另一条评论中提到的那样将它们注释掉)。
指示的手册页说:
This default behavior [of
fallocate
withmode
=0] closely resembles the behavior of the posix_fallocate(3) library function, and is intended as a method of optimally implementing that function.