Skip to content
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

Overeager warning for clashing external declarations in different wasm import modules #79581

Closed
pchickey opened this issue Nov 30, 2020 · 4 comments · Fixed by #80009
Closed
Assignees
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/

Comments

@pchickey
Copy link

pchickey commented Nov 30, 2020

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>

@pchickey pchickey added the C-bug Category: This is a bug. label Nov 30, 2020
@pchickey
Copy link
Author

cc @alexcrichton

@alexcrichton
Copy link
Member

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
Copy link
Contributor

jumbatm commented 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
Copy link
Member

No worries, and thanks! If you run out of time/steam I'm happy to look into this as well

@nagisa nagisa added O-wasm Target: WASM (WebAssembly), http://webassembly.org/ A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. labels Dec 2, 2020
@bors bors closed this as completed in 7a9b552 Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug. O-wasm Target: WASM (WebAssembly), http://webassembly.org/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants