X128: A Modest Proposal
I just got done reading today's cppfront update while some recent discussions about ABI were still on my mind, and that resulted in the following idea:
Why not define a new platform for which no existing software exists, but to which existing software could be easily ported? This would provide the freedom to make many desirable changes without worrying about breaking anything.
The ideal testbed for this experiment would be on Linux, because of the availability of source code ease of spinning up a "minimum viable operating system", consisting solely of a kernel image with an embedded initramfs which runs busybox. That's all you need to boot to a command line.
Linux also already supports multiple ABIs. The current reigning monarch of the desktop platforms is amd64, which is defined as, "the System V C ABI and the Itanium C++ ABI running on the LP64 instruction set".
A less well known but still supported alternative is X32 which is defined as, "amd46, except sizeof(void*) == 4".
So the minimum change necessary to define a new platform us to just tweak any of the implementation defined knobs in the C or C++ standards and now you have an opportunity to create new standard libraries which of course still must remain API compatible with their respective standards, but for which all potential QOI changes are on the table.
The smallest non-trivial change I can think of is the inspiration for the post title: X128 is defined as, "amd64, except sizeof(long) == 8 and sizeof(long long) == 16".
That change wasn't made 20 years ago when the System V ABI for AMD64 was defined because we were just starting the 32 bit to 64 bit transition and they wanted to preserve the ability to run software compiled for 32 bit. For the purposes of this thought experiment, however, requiring all software to be recompiled before it can run on the new platform is the explicit goal.
Realizing a proof of concept for this new platform would require porting four pieces of software: a C compiler and standard library, the kernel, and busybox.
After that the doors open to make any QOI changes to the C++ standard library (or C standard library for that matter) one desires. I'd suggest adding type erasure to std::regex and putting all standard library symbols in an inline version namespace, but that's just the most obvious low hanging fruit. Perhaps multithreaded stack unwinding to reduce the cost of exceptions would be another thing to consider.
Posted Sep 29, 2023, 1:28 PM UTC · edited
for that?