diff options
| author | bors <bors@rust-lang.org> | 2014-11-09 20:01:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-11-09 20:01:44 +0000 |
| commit | 507927299a85a72b60c274f5e293cc6596cbb2a0 (patch) | |
| tree | b816139f215bac2d26e0461b827d207f895b28ee /src | |
| parent | efc9a441b9f48912166b0ce375efe677edc0e93a (diff) | |
| parent | a722f70207cf8419150c52cbf79ef5b9eadb1639 (diff) | |
| download | rust-507927299a85a72b60c274f5e293cc6596cbb2a0.tar.gz rust-507927299a85a72b60c274f5e293cc6596cbb2a0.zip | |
auto merge of #18739 : vhbit/rust/issue-18574, r=alexcrichton
Fixes #18574
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/back/link.rs | 2 | ||||
| -rw-r--r-- | src/librustc_back/archive.rs | 27 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 58266f2ea32..30c76a7bf5f 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -734,7 +734,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) { let mut all_native_libs = vec![]; for &(cnum, ref path) in crates.iter() { - let name = sess.cstore.get_crate_data(cnum).name.clone(); + let ref name = sess.cstore.get_crate_data(cnum).name; let p = match *path { Some(ref p) => p.clone(), None => { sess.err(format!("could not find rlib for: `{}`", diff --git a/src/librustc_back/archive.rs b/src/librustc_back/archive.rs index db2f291e5e7..03b439b32c0 100644 --- a/src/librustc_back/archive.rs +++ b/src/librustc_back/archive.rs @@ -183,7 +183,7 @@ impl<'a> ArchiveBuilder<'a> { self.archive.slib_suffix.as_slice(), self.archive.lib_search_paths.as_slice(), self.archive.handler); - self.add_archive(&location, name, []) + self.add_archive(&location, name, |_| false) } /// Adds all of the contents of the rlib at the specified path to this @@ -193,13 +193,20 @@ impl<'a> ArchiveBuilder<'a> { /// then the object file also isn't added. pub fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool) -> io::IoResult<()> { - let object = format!("{}.o", name); - let bytecode = format!("{}.bytecode.deflate", name); - let mut ignore = vec!(bytecode.as_slice(), METADATA_FILENAME); - if lto { - ignore.push(object.as_slice()); - } - self.add_archive(rlib, name, ignore.as_slice()) + // Ignoring obj file starting with the crate name + // as simple comparison is not enough - there + // might be also an extra name suffix + let obj_start = format!("{}", name); + let obj_start = obj_start.as_slice(); + // Ignoring all bytecode files, no matter of + // name + let bc_ext = ".bytecode.deflate"; + + self.add_archive(rlib, name.as_slice(), |fname: &str| { + let skip_obj = lto && fname.starts_with(obj_start) + && fname.ends_with(".o"); + skip_obj || fname.ends_with(bc_ext) || fname == METADATA_FILENAME + }) } /// Adds an arbitrary file to this archive @@ -273,7 +280,7 @@ impl<'a> ArchiveBuilder<'a> { } fn add_archive(&mut self, archive: &Path, name: &str, - skip: &[&str]) -> io::IoResult<()> { + skip: |&str| -> bool) -> io::IoResult<()> { let loc = TempDir::new("rsar").unwrap(); // First, extract the contents of the archive to a temporary directory. @@ -295,7 +302,7 @@ impl<'a> ArchiveBuilder<'a> { let files = try!(fs::readdir(loc.path())); for file in files.iter() { let filename = file.filename_str().unwrap(); - if skip.iter().any(|s| *s == filename) { continue } + if skip(filename) { continue } if filename.contains(".SYMDEF") { continue } let filename = format!("r-{}-{}", name, filename); |
