Skip to content

Commit

Permalink
Fix our llvm::Bool typedef to be signed, to match LLVMBool
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Zalathar committed Dec 12, 2024
1 parent 903d297 commit f7c6a2c
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 f7c6a2c

Please sign in to comment.