On PowerPC AIX, there are special layout alignment rules for structs not represented by the repr(C)
attribute in Rust. Specifically, the layout of the following struct is misaligned:
#[repr(C)]
#[derive(Copy, Clone)]
pub struct Floats {
a: f64,
b: u8, // currently has 7 bytes of padding
c: f64,
}
While the same struct generated by Clang and GCC
struct Floats {
double a;
char b;
double c;
};
has the following layout
Layout: <ASTRecordLayout
Size:192
DataSize:192
Alignment:32
PreferredAlignment:64
FieldOffsets: [0, 64, 96]>
Layout: <CGRecordLayout
LLVMType:%struct.Floats = type <{ double, i8, [3 x i8], double, [4 x i8] }>
IsZeroInitializable:1
BitFields:[
]>
There are already existing infrastructure in rustc_target
to customize the target ABI calling convention for extern "C"
. I'm wondering what would be the best course of action to implement this special layout rule for repr(C)
?