Cross-compiling and the gen* native build tools

David Holmes david.holmes at
Tue Feb 4 06:46:02 UTC 2014

Hi Magnus,

On 4/02/2014 12:13 AM, Magnus Ihse Bursie wrote:
> I just noticed this when replying to a mail to Volker, but I think this
> is worth a thread on it's own.
> There are three very similar build helpers that are compiler with
> BUILD_CC, i.e. the compiler for the build (not target) platform. They are:
> jdk/src/solaris/native/sun/nio/fs/genUnixConstants.c
> jdk/src/solaris/native/sun/nio/fs/genSolarisConstants.c
> jdk/src/share/native/sun/nio/ch/genSocketOptionRegistry.c
> They are very similar in that they pick up (build) platform constants
> and turn them into Java constants.
> This does not work for cross-compilation, so we have closed sources
> hard-coded versions for these platform we internally cross-compile to.
> This does not strike me as a neat solution. You can't add a new target
> to cross compile to without mimicking our internal closed code
> structure. You are always needed to provide a build platform compiler,
> even though the results are not supposed to change for the platform
> you're building for. (If it were, then the resulting code would not be
> possible to run on any other platform then your own, i.e. it wouldn't be
> constants).
> I think we should do something similar to with the X11 wrappers, and
> hard-code the values, with a possible, optional, verification step.

I don't quite follow. What would you hard-code where? At present either 
the build platform is the target platform in which case you compile and 
run the appropriate generator; otherwise you have to have a hard-wired 
version of what the generator would produce on the target platform if 
you ran it there. I don't see a third choice.

Note that IIRC the X11 values don't change across platforms, whereas 
some of the constants in these files can/do.


> /Magnus

More information about the build-dev mailing list