0

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.

hetptis
  • 786
  • 1
  • 12
  • 23
  • 1
    Centos5 released 12 April 2007 - time to update? – Scary Wombat Jan 30 '19 at 02:20
  • Yeah, sadly we still have to support it for business reasons. – hetptis Jan 30 '19 at 02:32
  • My final goal was to build jdk11 on CentOS5. So I worked around this problem by commenting out references to fallocate64. Then I used jdk9 to build jdk10 and then jdk11. I used GCC 4.8.2, Beanutils 2.18 and other dependencies from https://people.centos.org/tru/devtools-2/5/x86_64/RPMS/ to build OpenJDK 11 on CentOS5. – hetptis Feb 04 '19 at 02:29

1 Answers1

1
  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.

ouflak
  • 2,458
  • 10
  • 44
  • 49