Requesting D ABI clarifications

Sean Kelly sean at f4.ca
Thu May 11 09:31:01 PDT 2006


pragma wrote:
> In article <e3u06e$2hg9$1 at digitaldaemon.com>, Gregor Richards says...
>> <preface>
>> I'm writing a D compiler using C as an intermediary language et cetera 
>> et cetera http://www.dsource.org/projects/tdc/
>> </preface>
>>
>> I have the lofty goal of DMD compatibility on those systems that DMD 
>> supports, but unfortunately the ABI spec on the page isn't complete ... 
>> I believe I have everything right (it seems to work) except for:
>>
>> A) Function calling semantics
>> 	- Some initial tests putting 'this' in %eax generated almost 100% 
>> compatible code, but there were occasional strange, difficult to trace 
>> errors - these could just be my mistakes, or I could be doing calling 
>> semantics improperly.  Is that the only major difference from C calling 
>> conventions, or is there something else specific I need to do?
>>
>> B) Exception handling
>> 	- For GNU/Linux, DMD's exception handling is for all intents and 
>> purposes undocumed ... it mentions that it has a static location for 
>> exception handling buffers, but that's about it.  I think I should be 
>> able to get SEH working (I've found a few nice docs on it), but don't 
>> have much of a base point for GNU/Linux ... all I know is a few symbols 
>> (_deh_end et al).
>>
>>
>> Could somebody (Walter?) either explain how these work in DMD or point 
>> me to where these are explained?  I would really like to be compatible, 
>> or at least as compatible as possible, with the reference ABI ... 
>> hopefully this is doable from C (I'm willing to use GCC __attribute__'s 
>> and inline assembly where necessary, this is how I got a parameter into 
>> %eax).
>>
>> Thanks for any response.
>>
>>  - Gregor Richards
> 
> Well, I do know that there are some variations in how D is supported across
> Windows and Linux.  I say this because Walter himself seems rather dubious that
> aiming for cross-platform runtime linking (ala DDL) is "folly" since there are
> subtle differences.  While I'd like to maintain that this only applies under
> certain circumstances, I honestly don't know what the baseline for binary
> compatiblity really is.

Ideally, it should be that libraries can be built with one compiler and 
linked against code compiled with another.  At the very least, this 
suggests that object layout, function calling conventions, and exception 
handling should be standardized for any specific platform.

> B) If memory serves, I think Walter went on the record as saying that the
> exception handling mechanisms are *different* between win32 and linux (the
> latter having to do with GDC/GDB compatibility I guess).  I hope I'm wrong about
> that, as this just seems to make life harder than necessary.  IMNSHO, using
> separate SEH mechanisms kind of ruins the idea of a true ABI.

While I think this is certainly possible, it would be somewhat more 
difficult as you wouldn't be able to use Windows SEH.  But perhaps 
binary compatibility between Windows and Unix platforms isn't a 
tremendous concern?


Sean



More information about the Digitalmars-d mailing list