-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
LLVM assertion failure for creating extern fns with same name but different signatures #16403
Comments
Closing as a dupe of #10883, but thanks for the report! |
@alexcrichton, in #10883 it's claimed that this error can only happen with Also, any suggestions for a workaround here? I'm not trying to link against my extern function, I just want to provide a pointer to it, so it'd be fine if its name gets mangled. This is inside of a macro, so having a unique name for the function every time the macro is used seems a little tricky. |
It's the same idea where the same symbol has two different types from LLVM's point of view, this just has a different trigger (but same underlying cause). Currently the only workaround is for the symbol to have the same type each time it's declared. |
I think this is a legitimately different error to #10883, since I believe the problem is we currently do other APIs by creating little wrappers that call to a function that has the Rust ABI. However, we currently don't make any effort to ensure that the name of that Rust ABI function pays attention to scoping. This is different to #10883 since it occurs simply by writing In any case, the fix is certainly different: this code should be able to compile, since the equivalent with As an example of this, consider fn main() {
{ extern fn foo() {} }
} target datalayout = "e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: uwtable
define internal void @_ZN4main20h1c12588f54a45a2feaaE() unnamed_addr #0 {
entry-block:
ret void
}
define i64 @main(i64, i8**) unnamed_addr #1 {
top:
%2 = call i64 @_ZN2rt10lang_start20h09857311e158dc649GyE(i8* bitcast (void ()* @_ZN4main20h1c12588f54a45a2feaaE to i8*), i64 %0, i8** %1)
ret i64 %2
}
declare i64 @_ZN2rt10lang_start20h09857311e158dc649GyE(i8*, i64, i8**) unnamed_addr #1
define internal void @_ZN4main3foo20h2bc621e3a5534caalaaE() unnamed_addr #1 {
"the block":
call void @_ZN4main3foo10__rust_abiE()
ret void
}
; Function Attrs: uwtable
define internal void @_ZN4main3foo10__rust_abiE() unnamed_addr #0 {
entry-block:
ret void
}
attributes #0 = { uwtable "split-stack" }
attributes #1 = { "split-stack" } The |
This now fails with
|
This no longer ICE's on stable through nightly currently fn main() {
{
extern fn foo() { }
}
{
extern fn foo(_bar: usize) { }
}
} but it does produce a not-so-nice error message:
|
The issue as reported (the ICE) has been fixed in a sense that rustc no longer ICEs in such case. We have a bunch of tests for related failures at As for whether failing in this case is the right thing to do™, we should fill a new issue IMO. |
The following crashes rustc:
It doesn't even give the nice ICE message, just this:
I am using
rustc 0.12.0-pre-nightly (4d4eb1023 2014-08-02 23:36:09 +0000)
. This issue looks similar to #5791?The text was updated successfully, but these errors were encountered: