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

The crate store does not deduplicate used crates #3474

Closed
brson opened this issue Sep 12, 2012 · 2 comments
Closed

The crate store does not deduplicate used crates #3474

brson opened this issue Sep 12, 2012 · 2 comments
Labels
A-linkage Area: linking into static, shared libraries and binaries A-metadata Area: Crate metadata

Comments

@brson
Copy link
Contributor

brson commented Sep 12, 2012

If you have code that links the same crate multiple times, the metadata loader may record several copies of the same crate in its crate list, e.g.

extern mod std(vers = "0.4");
extern std;

This could have potentially bad effects. It has already resulted a mysterious situation that caused all the crate hashes to change because of a spurious 'use'. I can imagine it also could cause types to not resolve if referenced from different mount points.

I believe that the metadata loader does make some effort to do this but it isn't sufficient.

@pnkfelix
Copy link
Member

Bug triage 2013jun24. I tried to construct an example where linking to the same crate multiple times would cause the types to not resolve, but I did not encounter any examples of such. Still, it would be good to fix this bug.

@huonw
Copy link
Member

huonw commented Dec 19, 2013

Triage: I think this may be fixed.

#[no_uv];

#[cfg(extra_crate)]
extern mod std;

fn main() {}
$ RUST_LOG=rustc::metadata::creader rustc --cfg extra_crate 3474.rs
resolving extern mod stmt. ident: @"std" path_opt: None
resolving deps of external crate
resolved crates:
cnum: 1u32
span: syntax::codemap::Span{lo: syntax::codemap::BytePos(0u32), hi: syntax::codemap::BytePos(0u32), expn_info: None}
hash: @"04ff901ef9eb93b7ed8d17b7ddf76fa8eb8b4c7295ad21af7133790d77381330"

and the output is the same without --cfg extra_crate. The above is full dump of the crate_cache list, clearly std doesn't appear twice (Without the no_uv there are two, rustuv and std).

@huonw huonw closed this as completed Dec 19, 2013
RalfJung pushed a commit to RalfJung/rust that referenced this issue May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-linkage Area: linking into static, shared libraries and binaries A-metadata Area: Crate metadata
Projects
None yet
Development

No branches or pull requests

3 participants