How to make D resolve C++ symbols by mangling symbols with the Itanium ABI on Windows

thumbgun thumbgun07 at gmail.com
Tue Feb 27 07:44:39 UTC 2024


On Monday, 26 February 2024 at 20:05:40 UTC, Johan wrote:
> On Monday, 26 February 2024 at 13:36:42 UTC, thumbgun wrote:
>> I'm currently trying to call some C++ functions that were 
>> compiled by g++ (mingw). However g++ uses the Itanium ABI name 
>> mangling rules. dmd on Windows tries to link functions based 
>> on the MSVC name mangling rules.
> ...
>> Is there any way I can make dmd link to symbols mangled 
>> according to the Itanium ABI's rules on Windows?
>
> Rather than the mangling names of functions, I'd be more 
> worried about calling conventions (something that mismatched 
> name mangling is supposed to help you with! ;-)).
>
> You can try with LDC and `-mtriple=x86_64-windows-gnu`.
>
> -Johan

The problem is that I have a library that was compiled by g++ 
(mingw). When I try to wrap it with extern (C++) DMD on Windows 
will try to link with symbols that are supposed to be mangled 
with MSVC.

Your point about calling conventions is right as the Itanium ABI 
specifies a different calling convention than MSVC. So I need a 
way for DMD to link against symbols mangled according to the 
Itanium ABI and then call the functions according to the Itanium 
ABI's calling convention. DMD currently supports this for other 
platforms but not for Windows.

LDC also uses DMD as a frontend so the problem could be the same 
but I'll try your suggestion anyway.


More information about the Digitalmars-d mailing list