Skip to content

Spurious multiple crate version warning when using --extern #17186

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

Closed
bkoropoff opened this issue Sep 12, 2014 · 0 comments · Fixed by #17189
Closed

Spurious multiple crate version warning when using --extern #17186

bkoropoff opened this issue Sep 12, 2014 · 0 comments · Fixed by #17189

Comments

@bkoropoff
Copy link
Contributor

Test Case

lib.rs

#![crate_name = "bar"]
#![crate_type = "rlib"]

test.rs

#![feature(phase)]

#[phase(plugin, link)]
extern crate foo;

fn main() {
}

Build

$ rustc lib.rs
$ rustc test.rs --extern foo=./libbar.rlib

Output

warning: using multiple versions of crate `bar`
test.rs:4:1: 4:18 note: used here
test.rs:4 extern crate foo;
          ^~~~~~~~~~~~~~~~~
note: crate name: bar
test.rs:4:1: 4:18 note: used here
test.rs:4 extern crate foo;
          ^~~~~~~~~~~~~~~~~
note: crate name: bar

Analysis

Use of #[phase(plugin, link)] causes the crate to be resolved twice. Looking at debug output, a bug is causing the two resolutions to load the same crate twice with separate cnums. I believe I have identified a fix and will be submitting a PR shortly.

bkoropoff added a commit to bkoropoff/rust that referenced this issue Sep 12, 2014
When checking for an existing crate, compare against the
`crate_metadata::name` field, which is the crate name which
was requested during resolution, rather than the result of the
`crate_metadata::name()` method, which is the crate name within
the crate metadata, as these may not match when using the --extern
option to `rustc`.

This fixes spurious "multiple crate version" warnings under the
following scenario:

- The crate `foo`, is referenced multiple times
- `--extern foo=./path/to/libbar.rlib` is specified to rustc
- The internal crate name of `libbar.rlib` is not `foo`

The behavior surrounding `Context::should_match_name` and the
comments in `loader.rs` both lead me to believe that this scenario
is intended to work.

Fixes rust-lang#17186
bkoropoff added a commit to bkoropoff/rust that referenced this issue Sep 13, 2014
bors added a commit that referenced this issue Sep 14, 2014
…ichton

When checking for an existing crate, compare against the `crate_metadata::name` field, which is the crate name which was requested during resolution, rather than the result of the `crate_metadata::name()` method, which is the crate name within the crate metadata, as these may not match when using the --extern option to `rustc`.

This fixes spurious "multiple crate version" warnings under the following scenario:

- The crate `foo`, is referenced multiple times
- `--extern foo=./path/to/libbar.rlib` is specified to rustc
- The internal crate name of `libbar.rlib` is not `foo`

The behavior surrounding `Context::should_match_name` and the comments in `loader.rs` both lead me to believe that this scenario is intended to work.

Fixes #17186
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 a pull request may close this issue.

1 participant