Cross-compilation of OpenJDK Zero with clang

Erik Joelsson erik.joelsson at oracle.com
Mon Jan 4 18:33:15 UTC 2021


Hello Andy,

Sorry for the late reply, but a lot of us have been on holiday.

I recommend starting with the main documentation in the source tree at 
doc/building.md. I have no personal experience using Clang for cross 
compilation, but I would imagine it would function similar enough to 
GCC. To instruct configure to look for Clang instead of GCC, use 
--with-toolchain-type=clang (also documented in said file). You will 
also need to use the --with-sysroot option to point to your target sysroot.

By default when cross compiling, a "build" jdk will also be built. This 
is a partial JDK native to the build system, which is used during the 
build. In many cases it makes more sense to explicitly build this once 
before trying to cross compile instead of having it weaved into your 
cross compile build. You can do that by simply building normally for 
your build platform first, and then point configure for your cross 
compile configuration to your newly produced native JDK using 
--with-build-jdk.

If you run into specific issues, you can followup with questions here.

/Erik

On 2020-12-17 08:13, Andy Nisbet wrote:
> Hi,
> I am in the process of porting OpenJDK to a new architecture, at the
> current moment in time we only have clang/LLVM cross compilation tools, and
> GCC/binutils is still a year or so away. Could anyone offer any pointers to
> documentation/hints, and/or outline what is necessary to get cross
> compilation with clang working?  I have a sysroot and a bootable diskimage
> for the virtual emulated platform.
>
> Thanks,
> Andy



More information about the build-dev mailing list