Cross-compiling and the gen* native build tools

David Holmes david.holmes at
Tue Feb 4 09:43:27 UTC 2014

On 4/02/2014 7:35 PM, Magnus Ihse Bursie wrote:
> 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.)

Correct we assume these values are constant for any given OS flavour 
(Linux, Solaris, OSX, BSD).

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

<sigh> The merry-go-round comes full circle one again. :) The generators 
exist to avoid the need to store platform specific files in the 
repository. Worked "perfectly" till we started cross-compiling. Then we 
had little choice but to allow for the pre-generated file to exist and 
not run the generator program.

> 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?

By platform here I meant OS+arch.


> /Magnus

More information about the build-dev mailing list