Closed
Description
Rustc 1.48.0 gives an incorrect warning about an external symbol being redeclared with a different signature, when the external symbols are in different wasm_import_module
namespaces.
I tried this code:
pub mod a {
#[link(wasm_import_module = "a")]
extern "C" {
pub fn foo();
}
}
pub mod b {
#[link(wasm_import_module = "b")]
extern "C" {
pub fn foo() -> usize;
}
}
I expected to see this happen: Compile without warnings
Instead, this happened:
warning: `foo` redeclared with a different signature
--> src/lib.rs:11:9
|
4 | pub fn foo();
| ------------- `foo` previously declared here
...
11 | pub fn foo() -> usize;
| ^^^^^^^^^^^^^^^^^^^^^^ this signature doesn't match the previous declaration
|
= note: `#[warn(clashing_extern_declarations)]` on by default
= note: expected `unsafe extern "C" fn()`
found `unsafe extern "C" fn() -> usize`
Meta
rustc --version --verbose
:
rustc 1.48.0 (7eac88abb 2020-11-16)
binary: rustc
commit-hash: 7eac88abb2e57e752f3302f02be5f3ce3d7adfb4
commit-date: 2020-11-16
host: x86_64-unknown-linux-gnu
release: 1.48.0
LLVM version: 11.0
The same behavior exists on nightly as well:
rustc 1.50.0-nightly (825637983 2020-11-18)
binary: rustc
commit-hash: 8256379832b5ecb7f71e8c5e2018446482223c12
commit-date: 2020-11-18
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly
Backtrace
<backtrace>
Activity
pchickey commentedon Nov 30, 2020
cc @alexcrichton
alexcrichton commentedon Nov 30, 2020
cc @jumbatm, would you be willing to help take a look at this? (it looks like you added this way-back-when in #70946)
On wasm targets there's special logic for symbol mangling which is why this should work but not actually generate a warning. Do you know if it's possible to call that logic from here perhaps? (would be able to consolidate "what's the name of this symbol" logic too!)
jumbatm commentedon Nov 30, 2020
Sure thing! I'm currently in the process of moving, but will be able to get onto this on the weekend :)
@rustbot claim
alexcrichton commentedon Dec 1, 2020
No worries, and thanks! If you run out of time/steam I'm happy to look into this as well
Auto merge of rust-lang#80009 - jumbatm:issue79581-overeager-clashing…