diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-06-18 17:55:24 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-06-19 12:56:31 +0000 |
| commit | 7ff0df51024a96e91f41c3760b5676ebbdc7a2c0 (patch) | |
| tree | 8edbf86c1312908227b499fb3e53a6edbfc9fcfc /compiler | |
| parent | 43929a8a75d85ae3939a80703bdd827e81c51ba5 (diff) | |
Fix "Remove src_files and remove_file"
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/archive.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/archive.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/archive.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 5 |
5 files changed, 20 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/archive.rs b/compiler/rustc_codegen_cranelift/src/archive.rs index 4822c7e03a9..e9b074e1837 100644 --- a/compiler/rustc_codegen_cranelift/src/archive.rs +++ b/compiler/rustc_codegen_cranelift/src/archive.rs @@ -92,7 +92,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { Ok(()) } - fn build(mut self) { + fn build(mut self) -> bool { enum BuilderKind { Bsd(ar::Builder<File>), Gnu(ar::GnuBuilder<File>), @@ -191,6 +191,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { ) }; + let any_members = !entries.is_empty(); + // Add all files for (entry_name, data) in entries.into_iter() { let header = ar::Header::new(entry_name, data.len() as u64); @@ -216,6 +218,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { self.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); } } + + any_members } fn inject_dll_import_lib( diff --git a/compiler/rustc_codegen_gcc/src/archive.rs b/compiler/rustc_codegen_gcc/src/archive.rs index 1975035ae20..999a54495ee 100644 --- a/compiler/rustc_codegen_gcc/src/archive.rs +++ b/compiler/rustc_codegen_gcc/src/archive.rs @@ -100,7 +100,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { Ok(()) } - fn build(mut self) { + fn build(mut self) -> bool { use std::process::Command; fn add_file_using_ar(archive: &Path, file: &Path) { @@ -133,6 +133,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { BuilderKind::Bsd(ar::Builder::new(File::create(&self.config.dst).unwrap())) }; + let any_members = !self.entries.is_empty(); + // Add all files for (entry_name, entry) in self.entries.into_iter() { match entry { @@ -193,6 +195,8 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { if !status.success() { self.config.sess.fatal(&format!("Ranlib exited with code {:?}", status.code())); } + + any_members } fn inject_dll_import_lib(&mut self, _lib_name: &str, _dll_imports: &[DllImport], _tmpdir: &MaybeTempDir) { diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 455c38ffb32..1f4bfffaafe 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -97,13 +97,14 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { /// Combine the provided files, rlibs, and native libraries into a single /// `Archive`. - fn build(mut self) { + fn build(mut self) -> bool { let kind = self.llvm_archive_kind().unwrap_or_else(|kind| { self.sess.fatal(&format!("Don't know how to build archive of type: {}", kind)) }); - if let Err(e) = self.build_with_llvm(kind) { - self.sess.fatal(&format!("failed to build archive: {}", e)); + match self.build_with_llvm(kind) { + Ok(any_members) => any_members, + Err(e) => self.sess.fatal(&format!("failed to build archive: {}", e)), } } @@ -270,7 +271,7 @@ impl<'a> LlvmArchiveBuilder<'a> { kind.parse().map_err(|_| kind) } - fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<()> { + fn build_with_llvm(&mut self, kind: ArchiveKind) -> io::Result<bool> { let mut additions = mem::take(&mut self.additions); let mut strings = Vec::new(); let mut members = Vec::new(); @@ -353,7 +354,7 @@ impl<'a> LlvmArchiveBuilder<'a> { }; Err(io::Error::new(io::ErrorKind::Other, msg)) } else { - Ok(()) + Ok(!members.is_empty()) }; for member in members { llvm::LLVMRustArchiveMemberFree(member); diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index 1c9fc217ea4..d2dd3fbcc99 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -50,7 +50,7 @@ pub trait ArchiveBuilder<'a> { where F: FnMut(&str) -> bool + 'static; - fn build(self); + fn build(self) -> bool; fn inject_dll_import_lib( &mut self, diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 0f528c119f3..b39a9c988c6 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -2503,8 +2503,9 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>( }) { sess.fatal(&format!("failed to build archive from rlib: {}", e)); } - archive.build(); - link_upstream(&dst); + if archive.build() { + link_upstream(&dst); + } }); } |
