Jump to content
David Millington

ABI Changes in RAD Studio 10.3

Recommended Posts

We made some changes to the low-level method call ABI in 10.3, which affects both Delphi and C++. This is likely to be invisible to you unless you do something very low-level. It's more visible to you if you use C++, because now an entire class of bugs has been fixed in one go.

 

IMO, whether you use C++ or not, it's very interesting!

 

Info here: https://community.idera.com/developer-tools/b/blog/posts/abi-changes-in-rad-studio-10-3

Edited by David Millington
  • Like 2
  • Thanks 4

Share this post


Link to post

 

@David Millington

Thanks for the nice article.
Does this change also affect/improve the compatibility with native VC libraries and Delphi ?

Share this post


Link to post
Quote
  • For Delphi, no visible effect - this is not something that is normally dug into by developers. If you have assembly code for Win64, you may want to check its handling of parameters between 4 and 8 bytes.

Well, not quite - it's not a common case but I want to point that out:

If you have any existing 64bit DLL that you compiled with a previous version and are now calling from a 10.3 compiled binary or vice versa that has any of the affected record types you are in trouble. You need to compile both with the same version.

 

Also if I am not mistaken it is between 5 and 8 bytes, 4 bytes fit into a register on both and should not be affected.

Edited by Stefan Glienke

Share this post


Link to post

4 bytes does fit into a register in both and is okay.  It is params of 5, 6, 7, and 8 bytes in size that prompted this work: that is, params that may or may not fit into a register depending on if the register is 4 bytes or 8 bytes in size. I updated to make that clearer.

 

Glad you find it interesting!

 

For VC compatibility: for cdecl and stdcall, possibly. We had a very comprehensive review of all calling conventions on all platforms. Other compatibility areas with VC can be very different areas, things like object file format or RTL or...

Share this post


Link to post

> However, if you need information (for example, perhaps you work on low-level code for profilers or debuggers, or have code for stack manipulation, inline assembly and naked functions, or similar) feel free to contact us.

 

Inquiring minds want to know! 🙂

Share this post


Link to post

Actually, there is a difference: Win64 compiler will be slightly different. What is expected to be a 64 bit pass-by-value has become a pass-by-reference parameter now.

 

Delphi will handle this transparently, but for assembler, there is a difference.

Edited by Rudy Velthuis
Typo

Share this post


Link to post
On 1/24/2019 at 12:19 PM, Stefan Glienke said:

If you have any existing 64bit DLL that you compiled with a previous version and are now calling from a 10.3 compiled binary or vice versa that has any of the affected record types you are in trouble. You need to compile both with the same version.

I would recompile the DLL, indeed, but make any parameter with 5-8 bytes explicitly a reference parameter: either var, out or const [ref], and adopt my calling code accordingly (in all versions I compile for). Then the ABI change doesn't matter.

 

Of course that doesn't help if you want to deploy the DLL to be used by different already deployed programs written with different versions. That is a big nuisance, IMO, and I wish they hadn't done this (I'd rather they had changed their C++ compilers).

 

But if there is a chance of recompiling, I would certainly use explicit reference passing.

Edited by Rudy Velthuis

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×