Source: r-base
Version: 4.5.0-1
Severity: normal
Tags: FTBFS patch
User: debian-loonga...@lists.debian.org
Usertags: loong64

Hi maintainers,

Compiling the rjava 1.0-11-1 failed for loong64 in the Debian Package Auto-Building environment.
The build error log(build error on 10 architectures)  is as follows,
```
checking whether sigsetjmp is declared... yes
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/lib/jvm/default-java/bin/java'
archiver    : '/usr/lib/jvm/default-java/bin/jar'
compiler    : '/usr/lib/jvm/default-java/bin/javac'
header prep.: ''
cpp flags   : ''
java libs   : ''
configure: error: One or more Java configuration variables are not set.
```
The full log of rjava can be found at
https://buildd.debian.org/status/package.php?p=rjava&suite=sid
https://buildd.debian.org/status/fetch.php?pkg=rjava&arch=loong64&ver=1.0-11-2&stamp=1744704288&raw=0

After analysis, the reason is that libjvm.so is not found when compiling rjava(depend r-base). For loong64 or other architectures(build zero in openjdk-21), libjvm.so was supported in /usr/lib/jvm/default-java/lib/zero/ [1][2], not /usr/lib/jvm/default-java/lib/server/. So we need to add "${boot_path}/zero" for OpenJDK zero build in r-base source package.

Please consider the patch I attached for r-base.
I have built r-base successfully in my local ENV.
The result of my local test command `R CMD javareconf`, JNI linker flags can be found normally for OpenJDK zero build:
```
# R CMD javareconf
Java interpreter : /usr/lib/jvm/default-java/bin/java
Java version     : 21.0.6
Java home path   : /usr/lib/jvm/default-java
Java compiler    : /usr/lib/jvm/default-java/bin/javac
Java headers gen.:
Java archive tool: /usr/lib/jvm/default-java/bin/jar

trying to compile and link a JNI program
detected JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/zero -ljvm
......
JAVA_HOME        : /usr/lib/jvm/default-java
Java library path: $(JAVA_HOME)/lib/zero
JNI cpp flags    : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/zero -ljvm
Updating Java configuration in /usr/lib/R
Done.
```

Based on my local r-base (r-base-core_4.5.0-1+loong64.1_loong64.deb), rjava is built successfully.
```
checking whether siglongjmp is declared... yes
checking Java support in R... present:
interpreter : '/usr/lib/jvm/default-java/bin/java'
archiver    : '/usr/lib/jvm/default-java/bin/jar'
compiler    : '/usr/lib/jvm/default-java/bin/javac'
header prep.: ''
cpp flags   : '-I/usr/lib/jvm/default-java/include -I/usr/lib/jvm/default-java/include/linux'
java libs   : '-L/usr/lib/jvm/default-java/lib/zero -ljvm'
checking whether Java run-time works... yes
......
   dh_builddeb -O--buildsystem=R
dpkg-deb: building package 'r-cran-rjava' in '../r-cran-rjava_1.0-11-1_loong64.deb'. dpkg-deb: building package 'r-cran-rjava-dbgsym' in '../r-cran-rjava-dbgsym_1.0-11-1_loong64.deb'.
 dpkg-genbuildinfo -O../rjava_1.0-11-1_loong64.buildinfo
 dpkg-genchanges -O../rjava_1.0-11-1_loong64.changes
```

BTW, I do not find the link how to contribute patch(submit pull request) via GITHUB to R source code upstream(https://contributor.r-project.org/). So I submitted this patch to debian r-base source package first and Cc upstream's r-devel@r-project.org.. Could you add the patch "Add "${boot_path}/zero" for OpenJDK zero build" in the next upload?
Your opinions are welcome.

[1]: https://github.com/openjdk/jdk/pull/5440
[2]: https://github.com/openjdk/jdk/pull/4787

Thanks,
Dandan Zhang

Description: Add "${boot_path}/zero" for OpenJDK zero build. 
 .
 r-base (4.5.0-1+loong64.1) unstable; urgency=medium
 .
   * src/scripts/javareconf.in: Add "${boot_path}/zero" for OpenJDK zero build.
Author: Dandan Zhang <zhangdan...@loongson.cn>

---
Last-Update: 2025-04-17

--- r-base-4.5.0.orig/src/scripts/javareconf.in
+++ r-base-4.5.0/src/scripts/javareconf.in
@@ -226,7 +226,7 @@ if test "${JAVA_LIBS}" = '~autodetect~';
 	if test ${has_libjvm} = no; then
 	    boot_path=`"$JAVA" -classpath "${tools_classpath}" getsp sun.boot.library.path| ${SED-sed} -e 's/:$//' -e 's/^://'`
 	    if test -n "${boot_path}"; then
-		for dir in "${boot_path}" "${boot_path}/client" "${boot_path}/server"; do
+		for dir in "${boot_path}" "${boot_path}/client" "${boot_path}/server" "${boot_path}/zero"; do
 		    if test -f "$dir/libjvm${DYLIB_EXT}"; then
 			has_libjvm=yes
 			java_library_path="${dir}"
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to