Cross-compiling and the gen* native build tools

Magnus Ihse Bursie magnus.ihse.bursie at oracle.com
Tue Feb 4 09:35:27 UTC 2014


On 2014-02-04 07:46, David Holmes wrote:
>
> 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.

Let me try again in different words. I'm not sure I'm 100% correct about 
this, but I'm basically thinking like this:

If you want to extract some kind of number, which will then be 
"hard-coded" into the built product as a constant (e.g. SYSTEM_FOO_VALUE 
in contrast to getPlatformFooValue()), then you must assume that this 
value will be constant on all your *target* platforms. Otherwise a JDK 
compiled on Fedora 8 will break when running on Ubuntu 12.10. So we 
know, or already assume, that the value selected when compiling for 
linux_x86 will be valid when running on all linux_x86 platforms. This 
situation is the same regardless of platform, and regardless of if we're 
cross-compiling or not. And we also does not expect these values to 
change as long as we support that platform. (If we find out they do, we 
need to rewrite the code to extract these values on runtime instead.)

So we could very well do the same for non-cross-compiles as we do for 
cross-compiles: generate this file once on the target platform, and then 
check it in. There's no point in running this tool once for every build.

The only thing we need to have is a tool to run on demand to help 
generate these kinds of files for new platforms.
>
> Note that IIRC the X11 values don't change across platforms, whereas 
> some of the constants in these files can/do.
As I argued above: If they in fact do, would that not cause a runtime bug?

/Magnus




More information about the build-dev mailing list