Cross compilation discussion

erik.joelsson at oracle.com erik.joelsson at oracle.com
Fri Dec 8 20:36:21 UTC 2023


On 12/8/23 08:29, Magnus Ihse Bursie wrote:
>
>> OK. So you are doing what I'd usually call cross compiling, sort of, but
>> you don't want to treat it as a cross-compiled build. It's an unusual
>> case, in that it is cross compiled, but it is also expected to be 
>> able to
>> run on the build system.
>
> The main reason for the build to know if we're doing a 
> cross-compilation or not has been if we need a special compiler to 
> create build tools. For me, that is in essence what the 
> cross-compilation flag is saying.
I think the issue now is that automatically figuring out if a separate 
compiler is needed or not can be hard. We do it in some cases, but not 
in others, and sometimes we get it wrong (as in the linux-aarch64 issue 
Mikael recently fixed, where the given tuple didn't exactly match what 
config.guess found on the build machine). I think it would be reasonable 
to have a configure parameter to control this explicitly.
>
> Separately, we have the concept of sysroot, but I agree that setting 
> the sysroot is essentially a form of cross-compilation. The question 
> is: do the build system need to know about this, any more than just 
> make sure we pass along the sysroot properly?
>
I agree that the purpose of the sysroot is to help configure find 
headers and libraries, and setup correct flags for compiler and linker 
tools.
> Maybe this is just a question on how to present the needs of the build 
> system to the user, where "cross-compilation" might have different 
> connotations than are used inside the build system.
>
> So maybe we should have like "cross-compiling-need-build-compiler" and 
> "cross-complining-can-use-target-compiler"?
>
Not sure of the naming here, but in essence, that's where we are making 
implicit assumptions today that are hard to control.

If you specify --with-openjdk-target and the tuple is different than the 
build tuple, then we can assume the default is to need a build compiler, 
but there are cases where that is still not strictly needed. If 
--with-build-devkit is supplied, then that is also a good indication as 
we are given an explicit build compiler. Just supplying a sysroot/devkit 
should probably not be assumed as needing a build compiler, but paired 
with a suitable option, this could support the cross compile to EL8 from 
EL7. I could for instance imagine setting --with-build-sysroot=/ to help 
nudge configure into defining a separate build compiler, but maybe 
that's too clunky?

/Erik


More information about the build-dev mailing list