C++ function calls using wrong calling convention

I'm working on building a plug-in for Adobe Illustrator. Adobe provides a C-based SDK (https://console.adobe.io/downloads) and some "wrapper" classes in C++.

I've generated bindings for all of this using bindgen. The wrapper classes are compiled into my project using cc crate. This all works well and gets linked nicely.

The problem I'm now running into is calling methods on the wrapper classes from my Rust code (C functions inside SDK work well). The methods are available and can be called, but the parameters don't get handed over correctly. Debugging the functionality revealed, that the parameters "vanish" once I cross the FFI border. Basically the pointer to the parameter value points into nirvana.

Looking into the registers shows:

  • rax and rdi both hold the correct address and the value is available there
  • rcx , rdx , and rsi all hold the address wrongly used on the C side for the function parameter

So I assume the wrong calling convention is used here.

Any ideas on how to fix this?

IIRC C++ has division between POD types and non-POD, which have different calling convention, and bindgen doesn't have information which is which.