loongarch64-unknown-linux-gnu extern "C"
ABI violates repr(transparent) on unions #115509
Closed
Description
The types (i32, f32)
and MaybeUninit<T>
do not have the same ABI, as demonstrated by this testcase:
#![feature(rustc_attrs)]
type T = (i32, f32);
#[rustc_abi(debug)]
extern "C" fn test1(_x: T) {}
#[rustc_abi(debug)]
extern "C" fn test2(_x: std::mem::MaybeUninit<T>) {}
fn main() {}
The first is
mode: Cast(
CastTarget {
prefix: [
Some(
Reg {
kind: Integer,
size: Size(4 bytes),
},
),
None,
None,
None,
None,
None,
None,
None,
],
rest: Uniform {
unit: Reg {
kind: Float,
size: Size(4 bytes),
},
total: Size(4 bytes),
},
attrs: ArgAttributes {
regular: (empty),
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
},
false,
),
The second is
mode: Cast(
CastTarget {
prefix: [
None,
None,
None,
None,
None,
None,
None,
None,
],
rest: Uniform {
unit: Reg {
kind: Integer,
size: Size(8 bytes),
},
total: Size(8 bytes),
},
attrs: ArgAttributes {
regular: (empty),
arg_ext: None,
pointee_size: Size(0 bytes),
pointee_align: None,
},
},
false,
),
RISC-V had the exact same issue, so the fix will likely also be the same.
I couldn't find an O-loongarch label.
Cc'ing the people listed on https://doc.rust-lang.org/rustc/platform-support/loongarch-linux.html
@hev @xiangzhai @zhaixiaojuan @xen0n