-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CFI: f32 and f64 are encoded incorrectly for cross-language CFI #115151
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
r? @bjorn3 |
compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
Outdated
Show resolved
Hide resolved
compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs
Outdated
Show resolved
Hide resolved
// Rust's f32 and f64 single (32-bit) and double (64-bit) precision floating-point types | ||
// have IEEE-754 binary32 and binary64 floating-point layouts, respectively. | ||
// | ||
// (See https://rust-lang.github.io/unsafe-code-guidelines/layout/scalars.html#fixed-width-floating-point-types.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to link to something describing the f
and d
prefixes that the encoding expects for IEEE-754 floats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm... those are just the Itanium C++ encoding for these builtin types (see https://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangling-builtin). Instead of referencing it, I think it makes more sense to explain why they can be directly used here (similarly to how it's explained in line 446 for ty::Bool). What do you think?
Fix rust-lang#115150 by encoding f32 and f64 correctly for cross-language CFI. I missed changing the encoding for f32 and f64 when I introduced the integer normalization option in rust-lang#105452 as integer normalization does not include floating point. `f32` and `f64` should be always encoded as `f` and `d` since they are both FFI safe when their representation are the same (i.e., IEEE 754) for both the Rust compiler and Clang.
d9f2b60
to
5d6e2d7
Compare
@bors r+ rollup |
Thank you for your time, @compiler-errors! Much appreciated. |
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#114754 (Name what ln_gamma does) - rust-lang#115081 (Allow overwriting ExpnId for concurrent decoding) - rust-lang#115151 (Fix CFI: f32 and f64 are encoded incorrectly for cross-language CFI) - rust-lang#115169 (remove some unnecessary ignore-debug clauses) - rust-lang#115190 (Add comment to the push_trailing function) r? `@ghost` `@rustbot` modify labels: rollup
Fix #115150 by encoding f32 and f64 correctly for cross-language CFI. I missed changing the encoding for f32 and f64 when I introduced the integer normalization option in #105452 as integer normalization does not include floating point.
f32
andf64
should be always encoded asf
andd
since they are both FFI safe when their representation are the same (i.e., IEEE 754) for both the Rust compiler and Clang.