Fix ICE on libcall signature mismatch - #1688
Conversation
| fn main() { | ||
| println!("{}", 2.0f32.powi(4)); | ||
| } | ||
|
|
||
| #[unsafe(no_mangle)] | ||
| fn __powisf2() -> f32 { | ||
| let r = 1f32; | ||
| r | ||
| } |
There was a problem hiding this comment.
I don't know much about clif organization unfortunately but having this in example/ seems weird?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@bjorn3 Should I revert that and put example/powi-libcall-signature.rs back?Happy to restore it if that’s what you prefer.
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 anunwrap(), 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