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

Check if the archive has already been added to avoid duplicates #62286

Merged
merged 1 commit into from
Jul 7, 2019
Merged
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
19 changes: 16 additions & 3 deletions src/librustc_codegen_llvm/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,20 @@ enum Addition {
name_in_archive: String,
},
Archive {
path: PathBuf,
archive: ArchiveRO,
skip: Box<dyn FnMut(&str) -> bool>,
},
}

impl Addition {
fn path(&self) -> &Path {
match self {
Addition::File { path, .. } | Addition::Archive { path, .. } => path,
}
}
}

fn is_relevant_child(c: &Child<'_>) -> bool {
match c.name() {
Some(name) => !name.contains("SYMDEF"),
Expand Down Expand Up @@ -188,12 +197,16 @@ impl<'a> LlvmArchiveBuilder<'a> {
-> io::Result<()>
where F: FnMut(&str) -> bool + 'static
{
let archive = match ArchiveRO::open(archive) {
let archive_ro = match ArchiveRO::open(archive) {
Ok(ar) => ar,
Err(e) => return Err(io::Error::new(io::ErrorKind::Other, e)),
};
if self.additions.iter().any(|ar| ar.path() == archive) {
return Ok(())
}
self.additions.push(Addition::Archive {
archive,
path: archive.to_path_buf(),
archive: archive_ro,
skip: Box::new(skip),
});
Ok(())
Expand Down Expand Up @@ -243,7 +256,7 @@ impl<'a> LlvmArchiveBuilder<'a> {
strings.push(path);
strings.push(name);
}
Addition::Archive { archive, skip } => {
Addition::Archive { archive, skip, .. } => {
for child in archive.iter() {
let child = child.map_err(string_to_io_error)?;
if !is_relevant_child(&child) {
Expand Down