Cross-compilation

I’m opening this discussion about cross-compilation in general for Haiku, as I have a few ideas / questions / information to share on this topic.

First, as mentioned in another thread, I would like to share the details about how cross-compiling WebKit2 for Haiku 32 bit from Linux system (Debian) was possible : Cross-compiling WebKit2 | Haiku Insider
I might complete this article in the future, as it was a first successful try, but there might be some enhancements in this process.

That being said, my current understanding on the status of cross-compilation for Haiku is as below:

  • Cross-compilation from Haiku 64 bit is not proposed today - as far as I know (for instance building Haiku 32 bit from Haiku 64 bit)
  • Cross-compilation from other systems is possible (see Pre-requisite Software | Haiku Project)
  • HaikuPorter has an option for cross-compilation but it’s not fully working today (I’ve tested this part a little bit for ARM64)

I’m not sure how hard it would be to have these features:

  • Be able to cross-compile Haiku 32 bit from Haiku 64 bit?
  • Be able to cross-compile packages to any supported platform (x86, arm64, etc) using HaikuPorter from a Linux system?

On my side, I’m more interested in the second option, as we might imagine (dream?) that in the future additional platforms might be eligible to Haiku (ARM64, …).
So having the possibility to generate packages directly from a powerful machine/system would make sense (imagine compiling packages from a slow Raspberry Pi machine…)

Any thoughts?

1 Like

realistically if this is implemented then 32 bit x86 will be supported. then i think riscv before arm64

It’s used in the bootstrap process (building Haiku packages for ARM 32 bit from a x86_64 Linux system is no problem). But it uses a different set of recipes (see the haikuports.cross repository) to achieve that, because in most cases, the cross compilation process isn’t transparent.

You need:

  • A compiler (you can build it using Haiku’s configure script)
  • A sysroot (done by the bootstrap script, but not so easily extracted from it). This has the Haiku system includes and libraries
  • Modified compiler/build tool options to make use of these things (haikuports.cross gives examples of this)

Jessicah had set this up when working on the Haskell port, you can find her script at GitHub - jessicah/cross-compiler: Building a Haiku cross-compiler with sysroot · GitHub

For building one package it’s easy, if you want to handle multiple packages with dependencies it can get a bit more complicated (especially as you don’t get to use packagefs in the case of a non-Haiku host). You can either extract all the hpkg you need to the sysroot, or use haikuporter as done in the bootstrap process.

When doing cross compilation, the host OS in theory shouldn’t matter. In practice, it often “leaks” some behaviors or path or other things into the built packages. Or just behaves unexpectedly.