Can we kill the D calling convention already?

Paulo Pinto pjmlp at progtools.org
Wed Apr 25 08:47:56 PDT 2012


On Wednesday, 25 April 2012 at 15:20:31 UTC, Don Clugston wrote:
> On 25/04/12 17:05, Paulo Pinto wrote:
>> On Wednesday, 25 April 2012 at 14:32:13 UTC, Alex Rønne 
>> Petersen wrote:
>>> On 25-04-2012 15:06, Kagamin wrote:
>>>> On Tuesday, 24 April 2012 at 10:29:52 UTC, Alex Rønne 
>>>> Petersen wrote:
>>>>> The point is just that: Right now I can write assembly that 
>>>>> will work
>>>>> on GDC, LDC, and DMD on non-Windows. It will not work for 
>>>>> DMD on
>>>>> Windows. Something has to change here.
>>>>
>>>> If it doesn't work on Windows, it should be versioned out. 
>>>> What we have:
>>>> http://dlang.org/version.html#PredefinedVersions - versions 
>>>> for LDC,
>>>> GDC, DMD and Windows - all what you want.
>>>
>>> Yes, I added them. :)
>>>
>>> You're missing the point. D is providing (or trying to 
>>> provide) a
>>> standard inline assembler, but calling conventions are not
>>> standardized enough for it to be useful across compilers. If 
>>> you're
>>> writing inline assembly because you *have* to, you don't just 
>>> "version
>>> it out", you have to write different logic for different 
>>> compilers,
>>> which is a maintenance nightmare.
>>
>> This is exactly what C++ gets blamed for, yet most people fail 
>> to
>> realize that the situation is common to all languages that 
>> generate
>> native code.
>
> No, it's totally the fault of C++. C++ failed to specify it, so 
> everyone did something different. Then you get this very 
> unfortunate mindset where everyone is so used to it, they don't 
> find it unacceptable any more.
>

As far as I am aware this is the same in all languages. I am not
aware of any ISO or ANSI language standard that specifies ABIs.

>> The only reason it works out for C, is that the C ABI is 
>> actually the OS
>> ABI, as such all C compilers tend to have a common ABI.
>
> Not true. The ABI for Win32 is __stdcall, not C. Pascal and 
> Fortran calling conventions were always well standardized, too.
>

For me this is the same, as all C compilers in Win32 are required
to generate __stdcall entry points. Plus since C is nothing more
than a glorified assembler, there is not much to speak about an 
ABI.
In a way the operating system can be seen as the C language 
runtime
(I am exaggerating a bit here).

Taking your language's example, which two FORTRAN or Pascal 
compilers,
in a given OS, are able to mix object or library files?

I am just defending that I should be able to combine a mix of 
libraries
compiled with DMD, LDC and GDC, without having to worry which is 
which.

--
Paulo


More information about the Digitalmars-d mailing list