[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Using java for cross compilation



Hello cross folks and Java folks,

I begin to recognize a pattern about cross building JNI things. I'll try 
to be a bit more verbose than usual to make this mail approachable by 
both cross folks and Java folks.

During cross compilation we compile a package on one machine (whose 
architecture we call build architecture) with the intention to install 
the resulting binary package on a different machine (whose architecture 
we call host architecture). A Java native interface manifests as 
dynamically loadable shared object file. When I look at packages that 
manage to successfully cross build such a thing, they typically request 
the Java development kit for the host architecture and also request the 
Java runtime environment for the build architecture. The most straight 
forward way of doing so would be

    Build-Depends: default-jdk, default-jre:native

in principle and we could append "-headless" if we wanted. 
Unfortunately, default-jdk Depends: default-jre and default-jre is 
"Multi-Arch: no", so we cannot coinstall default-jre:${DEB_BUILD_ARCH} 
and default-jre:${DEB_HOST_ARCH}. The underlying openjdk-${VERSION}-jre 
package however is "Multi-Arch: same" and it provides java-runtime (= 
${VERSION}). Using

    Build-Depends: default-jdk, java-runtime:native

tends to make cross building work practically, but the use of the 
virtual package means that the version of the native Java runtime is 
difficult to predict. Therefore, I am hesitant to propose patches to 
this end even though they tend to be harmless for native builds where 
dependencies of the default-jdk package trivially satisfy the later 
java-runtime:native dependency. It would be nice if there was a better 
express the practical need here.

One way to look at this is asking whether we could turn default-jre 
Multi-Arch: same and while that's simple for default-jre itself, it 
depends on default-jre-headless, which installs 
/usr/lib/jvm/default-java pointing to java-...-${DEB_HOST_ARCH} and this 
link would pose a conflict to Multi-Arch: same. Does someone see a way 
out of this?

Another angle is that most packages building a JNI presently declare 
Build-Depends on default-jdk or default-jdk-headless. Wouldn't it be 
nice if that dependency were causing the "right" packages to be 
installed for cross compilation? Then we would not have to change all 
those packages to add an additional :native Build-Depends to support 
cross compilation.

If going that route, there likely should be a new binary packages

    Package: default-jre-for-build
    Architecture: all
    Multi-Arch: foreign
    Depends: default-jre-headless-for-build, ???

    Package: default-jre-headless-for-build
    Architecture: all
    Multi-Arch: foreign
    Depends: ???

and the default-jdk and default-jdk-headless would then additionally 
depend on these new packages respectively. The open question here would 
be what they would have to depend on and what files (and symlinks) they 
should install. They'd probably depend on openjdk-${VERSION}-jre and 
openjdk-${VERSION}-jre-headless respectively.

A case where this practically matters is openmpi. It recently became 
cross satisfiable and now fails locating Java at the configure step. If 
adding java-runtime:native to Build-Depends, we may proceed, but that 
doesn't quite feel like the right solution.

I hope the Java folks may make sense of this and find an improvement on 
that side.

Helmut


Reply to: