Skip to content

Allow multiple libraries with the same hash. #32275

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
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/librustc_metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,13 @@ impl<'a> Context<'a> {
let slot = candidates.entry(hash_str)
.or_insert_with(|| (HashMap::new(), HashMap::new()));
let (ref mut rlibs, ref mut dylibs) = *slot;
fs::canonicalize(path).map(|p| {
if rlib {
rlibs.insert(p, kind);
} else {
dylibs.insert(p, kind);
}
FileMatches
}).unwrap_or(FileDoesntMatch)
let p = path.to_path_buf();
if rlib {
rlibs.insert(p, kind);
} else {
dylibs.insert(p, kind);
}
FileMatches
});
self.rejected_via_kind.extend(staticlibs);

Expand All @@ -462,8 +461,8 @@ impl<'a> Context<'a> {
let mut libraries = Vec::new();
for (_hash, (rlibs, dylibs)) in candidates {
let mut metadata = None;
let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
let rlib = self.extract_one(rlibs, "rlib", &mut metadata, true);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata, true);
match metadata {
Some(metadata) => {
libraries.push(Library {
Expand Down Expand Up @@ -521,7 +520,8 @@ impl<'a> Context<'a> {
// be read, it is assumed that the file isn't a valid rust library (no
// errors are emitted).
fn extract_one(&mut self, m: HashMap<PathBuf, PathKind>, flavor: &str,
slot: &mut Option<MetadataBlob>) -> Option<(PathBuf, PathKind)> {
slot: &mut Option<MetadataBlob>, dups_ok: bool)
-> Option<(PathBuf, PathKind)> {
let mut ret = None::<(PathBuf, PathKind)>;
let mut error = 0;

Expand Down Expand Up @@ -559,7 +559,7 @@ impl<'a> Context<'a> {
// based on a hash, however, then if we've gotten this far both
// candidates have the same hash, so they're not actually
// duplicates that we should warn about.
if ret.is_some() && self.hash.is_none() {
if ret.is_some() && !dups_ok {
let mut e = struct_span_err!(self.sess, self.span, E0465,
"multiple {} candidates for `{}` found",
flavor, self.crate_name);
Expand Down Expand Up @@ -707,8 +707,8 @@ impl<'a> Context<'a> {

// Extract the rlib/dylib pair.
let mut metadata = None;
let rlib = self.extract_one(rlibs, "rlib", &mut metadata);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata);
let rlib = self.extract_one(rlibs, "rlib", &mut metadata, false);
let dylib = self.extract_one(dylibs, "dylib", &mut metadata, false);

if rlib.is_none() && dylib.is_none() { return None }
match metadata {
Expand Down