Hitchikers Guide to Porting Phobos / D Runtime to other architectures

Iain Buclaw ibuclaw at ubuntu.com
Mon Apr 9 03:19:36 PDT 2012


On 9 April 2012 10:35, Jacob Carlborg <doob at me.com> wrote:
> On 2012-04-09 11:05, Johannes Pfau wrote:
>
>> * Adapting the core.stdc bindings to something different than the
>>   currently supported C libraries sucks: The version blocks are
>>   sometimes completely wrong. For example Android's bionic is a C
>>   library based on BSD code, but running on Linux. As a result
>>   sometimes the version(FreeBSD) blocks apply for bionic, but sometimes
>>   the version(linux) blocks are right. I basically had to rewrite
>>   the complete core.stdc bindings. This is an issue because druntime
>>   and phobos do not distinguish between OS/Kernel and C library.
>
>
> Is it possible to treat bionic as its own platform:
>
>
> version (bionic) {}
>
> else version (linux{}
>
> and so on.
>

Personally I feel that people porting to specific architectures should
maintain their differences in separate files under a /ports directory
structure - lets say core.stdc.stdio as a cod example. The version for
bionic would be under /ports/bionic/core/stdc/stdio.d, and that is the
module that gets compiled into the library when building for bionic.
When installing, the build process generates a header file of the
bionic version of core.stdc.stdio and puts the file in the correct
/include/core/stdc/stdio.di location.

Though it is fine to say using version {} else version {} else static
assert(false); when dealing with a small set of architectures.  I feel
strongly this is not practical when considering there are 23+
architectures and 12+ platforms that could be in mixed combination.
The result would either be lots of code duplications everywhere, or
just a wiry long block of spaghetti code.  Every port in one file
would (eventually) make it difficult for maintainers IMO.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the Digitalmars-d mailing list