GCC Hybrids
What is a GCC Hybrid?
With changeset 25536, it became possible to build Haiku as a GCC Hybrid. In such a case, Haiku will be capable of running binaries that are compiled with either GCC 2.95 or GCC 4.x. As of revision 30875, it became possible to use a GCC Hybrid to compile objects for either GCC.
In a GCC Hybrid, there is the main GCC and the alternative GCC. The main GCC is the version that was used to compile Haiku. The alternative GCC provides both a runtime time environment and a cross-compiler for using and creating other-GCC objects. Switching between compilers is done with a simple command : setgcc -h.
Since x86 is the only platform for which BeOS R5 binary compatibility is possible, no other target platforms need to be built with gcc2. Thus, x86 is the only platform that a GCC 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.
Due to the way Haiku handles libraries and related files, it is easier to run BeOS R5 programs on a GCC 2 Hybrid. For example on a GCC 2 Hybrid, libraries built with gcc2 belong in */lib/ and those built with gcc4 need to be in */lib/gcc4/. Since BeOS software is not aware of this convention, it will unconditionally install its libraries into */lib/. As a result, there may be issues with any software that does not take this convention into account.
Why not GCC 4?
Even though GCC 4 has stronger optimization algorithms, the performance increase from compiling Haiku with GCC 4 is nil to none. More importantly, 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?
Setting up directories
/path/haiku/buildtools/ /path/haiku/haiku/ /path/haiku/haiku/generated.x86gcc2 /path/haiku/haiku/generated.x86gcc4
Configuring the directories
...within Haiku
As such, it is easiest to use a GCC Hybrid. Otherwise you will need to manually install the
missing compiler. Looking at OptionalPackages's code block will reveal the URLs of the compilers.
cd generated.x86gcc4 ../configure --alternative-gcc-output-dir ../generated.x86gcc2 --cross-tools-prefix /boot/develop/abi/x86/gcc4/tools/current/bin/ cd .. cd generated.x86gcc2 ../configure --alternative-gcc-output-dir ../generated.x86gcc4 --cross-tools-prefix /boot/develop/abi/x86/gcc2/tools/current/bin/ cd ..
...from another OS
cd generated.x86gcc2 ../configure --alternative-gcc-output-dir ../generated.x86gcc4 --build-cross-tools ../../buildtools/ cd .. cd generated.x86gcc4 ../configure --alternative-gcc-output-dir ../generated.x86gcc2 --build-cross-tools-gcc4 x86 ../../buildtools/ cd ..
Jamming inside one of the generated folders
GCC 2.95 with GCC 4.x as secondary libraries (x86gcc2hybrid)
cd generated.x86gcc2 jam -q @nightly-raw
