Haiku Hybrids

What is a Haiku Hybrid?

Haiku hybrid images are Haiku releases which can compile and execute programs built for incompatible ABIs. This may mean different architectures like x86-64 and x86, or different, incompatible compilers like GCC 2.95 and GCC 4.x for x86. Currently only the latter case is supported. GCC 2.95 gives Haiku binary compatibility with native legacy applications written for the BeOS.

In a Haiku Hybrid, there is the primary GCC or architecture and the secondary GCC or architecture. The primary GCC is the version that was used to compile Haiku. The secondary GCC provides both a runtime time environment and a cross-compiler for using and creating other-GCC objects.

The architecture name used in the build system and in Haiku for x86 GCC 2 is "x86_gcc2" and for x86 GCC 4 "x86". In a Haiku Hybrid one can find subdirectories named like the secondary architecture in */lib/, */bin/, and other directories. They contain files specific to the secondary architecture portion of the Hybrid.

Since x86 is the only platform for which BeOS R5 binary compatibility is possible, no other target platforms need to be built with GCC 2. Thus, until x86-64 Haiku has grown 32 bit support, x86 is the only platform that a Haiku Hybrid is usable.

Which GCC should I use?

In short, a GCC 2 Hybrid. For R1 and earlier releases, GCC 2 Hybrid is the official release style. As such you can expect the least amount of issues on it. Later we will likely switch to GCC 4 Hybrids and eventually phase out the GCC 2 part completely.

Why not GCC 4?

For R1 and earlier releases, only the GCC 2 ABI can be considered stable and future proof. Once R1 is released, binaries built with GCC 4 will need to be recompiled (and more than likely have their sources updated for new API).

How are GCC Hybrids built?

Hybrids are built pretty much the same way as non-Hybrids. The only difference is that when configuring the build the secondary architecture respectively the secondary compiler needs to be specified.

Setting up directories

Your working directory (also called a folder) may look like this:

  sourcecode/haiku/buildtools/
  sourcecode/haiku/haiku/
  sourcecode/haiku/haiku/generated.x86gcc2

You have created sourcecode/haiku/ and from there cloned the Haiku repo (which created the haiku subfolder). If you're not building under Haiku, you also cloned the Buildtools repo (which created the buildtools subfolder). Now create the folder sourcecode/haiku/haiku/generated.x86gcc2.

Configuring the directories

Be sure to consult the various configure options, such as --use-gcc-pipe, --use-xattr-ref, and -j<N>

...within Haiku

To build Haiku Hybrids within Haiku, both the GCC 2.95 and GCC 4.x compilers are needed.
As such, it is easiest to use a (matching or swapped) Haiku Hybrid. Otherwise you will need to have configure build the missing compiler, which only works for a GCC 4.x Haiku, since GCC 4.x cannot be built with GCC 2.95.
  cd generated.x86gcc2
  ../configure --target-arch x86_gcc2 --target-arch x86

...from another OS

  cd generated.x86gcc2
  ../configure --build-cross-tools x86_gcc2 ../../buildtools/ --build-cross-tools x86

To build a GCC 4 Hybrid simply swap the order of the specified architectures "x86_gcc2" and "x86".

Jamming inside one of the generated folders

Be sure to consult the various jam options.
  cd generated.x86gcc2
  jam -q @nightly-raw

I