Skip to content

fix(rustc_codegen_nvvm): Check function signatures before overriding libm functions. #206

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

Merged
merged 1 commit into from
May 1, 2025

Conversation

jorge-ortega
Copy link
Collaborator

libm 0.2.13 refactored some of its implementations to use generic functions. The monomorphized function names clashed with the function names the codegen would override, causing it the codegen to override the function to a libdevice call that did not match the function signature. It then tries to patch this with a bitcast betwen floating point types, which are invalid casts.

This change adds an additional check before overriding. The libm function signature must match the libdevice intrinsic signature of the same name. Note that this prevents overrides even if bitcasts between the two argument types would be valid, which is likely another bug anyways.

fixes #205

…libm functions.

libm 0.2.13 refactored some of its implementations to use generic functions. The monomorphized function names clashed with the function names the codegen would override, causing it the codegen to override the function to a libdevice call that did not match the function signature. It then tries to patch this with a bitcast betwen floating point types, which are invalid casts.

This change adds an additional check before overriding. The libm function signature must match the libdevice intrinsic signature of the same name. Note that this prevents overrides even if bitcasts between the two argument types would be valid, which is likely another bug anyways.
@LegNeato
Copy link
Contributor

LegNeato commented May 1, 2025

This hit rust-gpu as well: Rust-GPU/rust-gpu#242

@LegNeato LegNeato merged commit 3c2e043 into Rust-GPU:main May 1, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Latest libm 0.2.13 is failing during LTO
2 participants