Porting D to custom OS

Iain Buclaw ibuclaw at gdcproject.org
Sat Feb 22 15:15:43 UTC 2020


On Saturday, 22 February 2020 at 13:20:40 UTC, IGotD- wrote:
> I'm trying to find information how to port D, especially the D 
> runtime to a proprietary OS. The OS support seems to be 
> scattered around several files with a lot version (OS) 
> switches. This makes kind of hard to understand what you have 
> to implement. Also, what happens if you only have partial 
> support, for example networking is completely left out.
>
> Will there be a future improvement of this so that OS specific 
> support can be moved to separate files and selected on module 
> level instead? For example.
>
> void DSpecificLibraryFunction(...)
> {
>     OSDependentLibraryFunction(...)
> }
>
> so that there are predefined OS specific functions that are 
> selected on module level. Also version() switches where 
> everything is consolidated into one file makes it more 
> difficult to merge.
>
> Do we have any guide for OS porting?

Best place to start would be without druntime at all, just a 
minimal object module, and extern(C) main, then work your way up, 
introducing each module one at a time to make sure that it all 
works.

There are a few core components that you need to port in order to 
get things working, or at least, you need to isolate and verify 
that it works, as if they don't then you'll get some very hard to 
debug issues.

The two main ones to pay close attention to are rt.sections and 
core.thread.  If exception handling is not dwarf-based, then 
you'll have to implement your own rt.deh too.


More information about the Digitalmars-d-learn mailing list