-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Description
With the MSVC x64 ABI, structs are returned in RAX if and only if they are <= 8 bytes in size, and are effectively a POD type. See https://msdn.microsoft.com/en-us/library/7572ztz4.aspx . Unfortunately, I can't figure out how to tell Rust this. In C++, sk_sp<T> has a user-defined constructor, destructor, etc. In Rust, I couldn't figure out any way to do this. It's defined as..
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct sk_sp<T> {
pub ptr: *mut T,
}
This causes segfaults because the C++ calling convention isn't upheld. A temporary workaround is to just add another dummy field, making this type bigger than 8 bytes. This happens to work in this case since this type is only ever used as a smart pointer return type; params are passed as basic T*.
Is there any way to tell rustc to treat this type as non-POD when giving it to LLVM? If not, can such a mechanism be added?