Compiler interoperability

Basile B. basile.b at gmx.com
Fri Jul 7 09:01:21 UTC 2023


On Friday, 7 July 2023 at 08:19:28 UTC, Chris Katko wrote:
> For a specific system (Linux, e.g):
>
> What is the level of interoperability between the different D 
> compilers; DMD, LDC, and GDC?
>
> It appears each one has different benefits, and, different 
> experimental features. Link-time optimization for LDC. GDC 
> offering static analysis. I imagine there are more.
>
> If I compile a D program with say, DMD, will every D library I 
> include also have to use that same compiler

Yes because of exception handling, the runtime functions are 
different.
You can try and you'll see linking error because of a missing 
"*personality*",
symbol.

> (and compiler version) from scratch and need recompiled?

 From version to version of a same vendor that might work but as 
phobos is not binary compatible (ABI of functions is allowed to 
change from a version to another) this is a bit the lottery.

> Or is there a pre-defined ABI that makes everything compatible? 
> If I use shared libraries instead of static linking, does the 
> situation change?
>
> Additionally, how do the debuggers GDB vs LLDB behave when 
> compiled using a different brand D compiler? (e.g. demangling)

Mangling is identical for each vendor (this is a language spec) 
but as mentioned, EH functions are different so the breakpoint 
set to break on `throw` for DMD (i.e `_d_throwdwarf`) will not 
work for `LDC` (i.e `_d_throw_exception`)

> I have my own experiences but I'm not sure if there's clear cut 
> "yes, definitely it's [this case]." answers out there.

So to conclude there's no interoperability




More information about the Digitalmars-d-learn mailing list