[D-runtime] Use of X86 and X86_64 in druntime and phobos

Alex xtzgzorex at gmail.com
Fri Nov 25 21:26:05 PST 2011


Hi folks,

I've noticed an annoying trend in druntime and phobos of using the X86
and X86_64 version identifiers to make _bitness-dependent_ decisions.
Some code goes along the lines of:

version (X86)
{
    ...
}
else version (X86_64)
{
    ...
}
else
    static assert(false, "Unknown platform");

In some cases, the assert isn't even present, so you just end up with
compile errors that you need to go and investigate.

There's also code such as:

version (X86)
{
    ...
}
else
{
    ...
}

(Notice the unconditional else clause.)

This makes porting of druntime and phobos to non-x86 architectures a
massive pain; there are so many places that need to be checked by hand
or they won't work correctly on either 32-bit or 64-bit architectures
(and in some cases, you won't get any error at compile-time, but
rather observe a runtime crash).

I realize most non-DMD compilers maintain their own druntime/phobos
trees, but one has to keep in mind that upstream druntime/phobos are
merged into these regularly. I believe it is in everyone's best
interest if we stop abusing architecture version identifiers as
bitness version identifiers. IOW, use D_LP64 instead of X86 and
X86_64.

If we can agree on this, I'll gladly submit some patches to both
projects to sort this out.

(I ran into these issues while building GDC as an ARM cross-compiler.)

Regards,
Alex


More information about the D-runtime mailing list