librustc_codegen_llvm: Use repr(transparent) for bitflags over repr(C) (#61306)
authorJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Sun, 16 Jun 2019 00:53:33 +0000 (02:53 +0200)
committerXimin Luo <infinity0@debian.org>
Sat, 13 Jul 2019 17:30:35 +0000 (18:30 +0100)
In order to make sure that Rust's bitflags types are passed the same
way in the Rust ABI as they are in the C ABI, we need to use the attribute
repr(transparent) over the repr(C) attribute for the single-field bitflags
structs in in order to prevent ABI mismatches. Thanks to Michael Karcher
for finding this bug.

Gbp-Pq: Name u-sparc64-ffi-abi.patch

src/librustc_codegen_llvm/llvm/ffi.rs

index f6ee8bec16a5ac4251abc23f8508b8444ba938b8..9a99738534c7b6f6fdd2f442c91d9d09bbe1cf7e 100644 (file)
@@ -564,7 +564,7 @@ pub mod debuginfo {
 
     // These values **must** match with LLVMRustDIFlags!!
     bitflags! {
-        #[repr(C)]
+        #[repr(transparent)]
         #[derive(Default)]
         pub struct DIFlags: ::libc::uint32_t {
             const FlagZero                = 0;
@@ -593,7 +593,7 @@ pub mod debuginfo {
 
     // These values **must** match with LLVMRustDISPFlags!!
     bitflags! {
-        #[repr(C)]
+        #[repr(transparent)]
         #[derive(Default)]
         pub struct DISPFlags: ::libc::uint32_t {
             const SPFlagZero              = 0;