abi-compliance-checker icon indicating copy to clipboard operation
abi-compliance-checker copied to clipboard

Doesn't detect change to x64 ABI calling convention due to C++ struct definition change

Open unwiredben opened this issue 9 months ago • 1 comments

Here's a fun issue that I found recently.

In the x64 System V ABI, the calling convention used to pass structs via registers as opposed to via pointers to memory depends on if the struct is considered trivial according to the Itanium C++ ABI.

This means that if you define this struct

struct v {
    float a, b;
};

it can be passed in a single SSE register. However, if you add an empty destructor

struct v {
    float a, b;
    ~v() { }
};

then the class becomes non-trivial and it has to be passed via a pointer instead.

This didn't affect ARM32 compilation (the struct was too large for a register) or MIPS32 compilation (only uses pointers), but broke when build for a desktop simulator.

abi-tests.zip

unwiredben avatar May 24 '24 19:05 unwiredben