Context
It is well known that Haiku on 32-bit x86 uses the legacy GCC2 ABI for compatibility with BeOS applications. To build binaries with this ABI, we rely on GCC 2.95, a legacy compiler that does not work on modern hosts (e.g. x86_64-linux) and sometimes suffers from bitrot.
Furthermore, the compiler does not support modern versions of C/C++. To have newer apps ported to x86, Haiku currently requires a “hybrid” - a build with duplicate system libraries, one with the legacy GCC2 ABI, one with the modern ABI built by newer compilers. This hybrid setup introduces complexity both when building software and when using it.
A recent attempt has been made to patch the LLVM toolchain to generate GCC2-compatible binaries. The port has proven success with working GCC2 ABI binaries on both Linux and Haiku x86_gcc2.
There has been a proposal to allow gradually upstreaming these changes to the LLVM project. While there is no fundamental objection and efforts have been made to resolve technical concerns, the Clang maintainers want evidence of support from the Haiku community to justify the addition of this legacy ABI to the codebase:
The Clang Area Team did discuss it very briefly and our biggest concern boils down to “is there enough of a need to warrant supporting it forever?” kinds of questions. For example, if you can point to discussions within the Haiku community that they need this support and are bought into the idea, that would help strengthen the RFC.
If Clang added support for producing x86_gcc2 binaries, would you, the Haiku community, adopt it?
Benefits include:
- No more
setarch x86to use tools. - No more
$secondaryArchSuffixin recipes. - No more split dependencies for
x86_gcc2. - Fewer downstream patches for
haiku/buildtools.
My adoption plan
Stage 1: HaikuPorts
Step 1: Existing Package
Once the RFC to LLVM is accepted, the GCC2 ABI backend can be added to HaikuPorts. It will be built into the existing llvm<version>_clang_x86 package and made available to Haiku users while upstreaming work is taking place.
Step 2: New Ports
The new llvm_clang_x86 package can then be used as a build dependency. We can use that to build ports that were previously broken/unsupported on x86_gcc2 - including a native llvm_clang port for GCC2.
Step 3: Unified Ports
With the new x86_gcc2 ecosystem stabilizing, we can start unifying the ports under clang and removing secondary architecture workarounds.
Stage 2: Haiku
Step 0: Misc. Fixes
This stage will happen alongside Stage 1. There will be no fundamental changes on how Haiku is built. However, we will make small changes that facilitates the porting of modern binaries to the x86_gcc2 environment. Examples of such changes include:
- https://review.haiku-os.org/c/haiku/+/11059 (already has +1)
- Making legacy STL headers in Haiku compile with a modern compiler (endorsed by waddlesplash).
Step 1: Build Packages
Once proven usable in the HaikuPorts ecosystem, Clang-built packages can be used as dependencies for x86_gcc2 system libraries/apps. The apps themselves will still use x86_gcc2.
Step 2: Side-by-Side Configuration
Once Clang is more stable, we can experiment with building using the LLVM toolchain. Some configuration to the Jam build system may be needed.
Step 3: Migration
Once the system can be built using Clang with no issues, we can migrate to Clang as the default compiler. Once this is achieved, we will only require one toolchain for x86.
The GCC 2.95 port can still be maintained in HaikuPorts for building legacy non-conforming C++ codebases.
It would be really nice if you could comment your thoughts on this. If you like support this idea but don’t know what to say, a
would be greatly appreciated!