Skip to content

Commit

Permalink
Rollup merge of #134204 - Zalathar:llvm-bool, r=SparrowLii
Browse files Browse the repository at this point in the history
Fix our `llvm::Bool` typedef to be signed, to match `LLVMBool`

In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`, but our Rust-side typedef was using `c_uint` instead.

Signed and unsigned integers have the same ABI on most platforms, but that isn't universally true, so we should prefer to be consistent with LLVM.

https://github.com/rust-lang/llvm-project/blob/1268e87/llvm/include/llvm-c/Types.h#L28
  • Loading branch information
matthiaskrgr authored Dec 12, 2024
2 parents f620e46 + f7c6a2c commit 6d79df6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ use super::debuginfo::{
DebugEmissionKind, DebugNameTableKind,
};

pub type Bool = c_uint;
/// In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`,
/// which has a different ABI from Rust or C++ `bool`.
pub type Bool = c_int;

pub const True: Bool = 1 as Bool;
pub const False: Bool = 0 as Bool;
Expand Down

0 comments on commit 6d79df6

Please sign in to comment.