Skip to content

Fix ICE on libcall signature mismatch - #1688

Open
0xmuon wants to merge 4 commits into
rust-lang:mainfrom
0xmuon:fix8
Open

Fix ICE on libcall signature mismatch#1688
0xmuon wants to merge 4 commits into
rust-lang:mainfrom
0xmuon:fix8

Conversation

@0xmuon

@0xmuon 0xmuon commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Description

When code calls f32.powi(),Cranelift lowers it to a libcall named __powisf2.If you also define your own #[no_mangle] fn __powisf2() with the wrong signature, backend tried to declare the symbol twice with different types and hit an unwrap(), which caused an internal compiler error instead of a normal error message.
I fixed it by pulling the import declaration logic into a shared helper and using that for libcalls too,so signature conflicts now fail with a clear “attempt to declare __powisf2…” message like other function imports already do.

I also added a small repro in example/powi-libcall-signature.rs and a test to make sure this case errors cleanly and never ICEs again.

fixes: #1682

Comment thread example/powi-libcall-signature.rs Outdated
Comment on lines +1 to +9
fn main() {
println!("{}", 2.0f32.powi(4));
}

#[unsafe(no_mangle)]
fn __powisf2() -> f32 {
let r = 1f32;
r
}

@tgross35 tgross35 Aug 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about clif organization unfortunately but having this in example/ seems weird?

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it in example/ because that is where the other regression inputs live (issue-72793.rs, float-minmax-pass.rs)and the build system already knows how to compile files from there. I treated it like those other cases i.e: a small program the test harness builds.

this one is really a compile fail check, not a normal “build and run” example.
i will remove this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not meant to be run as a standalone sample, it only exists to trigger a specific compiler error under Cranelift. Keeping a separate file there is confusing.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know much about clif organization unfortunately but having this in example/ seems weird?

It is the correct location. The name is a legacy artifact of when I initially created cg_clif and placed some example code to test compilation with there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bjorn3 Should I revert that and put example/powi-libcall-signature.rs back?Happy to restore it if that’s what you prefer.

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.

ICE IncompatibleSignature

3 participants