hetptis
hetptis

Reputation: 806

Build OpenJDK 9 in CentOS5

I was trying to build OpenJDK 9 in Centos 5. I used

sh ./configure --disable-warnings-as-errors
make all

I am getting the following error.

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

I also tried other make targets such as make images and make install. But still getting the same error. My GCC version is gcc (GCC) 4.4.7 which I manually installed because Centos 5 by default has an older version.

Upvotes: 0

Views: 277

Answers (1)

Youssef Mubarak
Youssef Mubarak

Reputation: 26

  1. Building JDK requires at least GCC 5.0 (see Building the JDK: CC).

  2. This seems to be a problem in the glibc version (see redhat-issue, util-linux). So, updating your glibc to the latest version might solve it.

  3. If you don't want to update your system's glibc, here is another alternative:

By looking at the man page of fallocate, we find that the description mentions that posix_fallocate(3) is a portable, POSIX.1-specified version of it, in case the mode parameter has the default value (0). The same applies to fallocate64. Since all the occurrences of the aforementioned error already use the default mode value, you can replace them with posix_fallocate64() (instead of commenting them out as you mentioned in another comment).

The denoted man page says that:

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.

Upvotes: 1

Related Questions