diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-28 08:43:15 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2022-07-28 08:43:15 +0000 |
| commit | 90da3c6f2b4db9bde02138830de1ea14982b1512 (patch) | |
| tree | 9e66f93b3c98a26d370b8fb81d280cee1561ff6b | |
| parent | 7c93154a30a640b8120c5aca68bffb886dcd02e6 (diff) | |
| download | rust-90da3c6f2b4db9bde02138830de1ea14982b1512.tar.gz rust-90da3c6f2b4db9bde02138830de1ea14982b1512.zip | |
Inline inject_dll_import_lib
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/archive.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_gcc/src/archive.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/back/archive.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/archive.rs | 23 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 7 |
5 files changed, 6 insertions, 36 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/archive.rs b/compiler/rustc_codegen_cranelift/src/archive.rs index 9d39b4aa661..e28c3813d3f 100644 --- a/compiler/rustc_codegen_cranelift/src/archive.rs +++ b/compiler/rustc_codegen_cranelift/src/archive.rs @@ -219,10 +219,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { any_members } - fn sess(&self) -> &Session { - self.sess - } - fn create_dll_import_lib( _sess: &Session, _lib_name: &str, diff --git a/compiler/rustc_codegen_gcc/src/archive.rs b/compiler/rustc_codegen_gcc/src/archive.rs index a8e94ad4b8d..f7745951d28 100644 --- a/compiler/rustc_codegen_gcc/src/archive.rs +++ b/compiler/rustc_codegen_gcc/src/archive.rs @@ -172,10 +172,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> { any_members } - fn sess(&self) -> &Session { - self.config.sess - } - fn create_dll_import_lib( _sess: &Session, _lib_name: &str, diff --git a/compiler/rustc_codegen_llvm/src/back/archive.rs b/compiler/rustc_codegen_llvm/src/back/archive.rs index 8d6e3673271..21a1e3a3b82 100644 --- a/compiler/rustc_codegen_llvm/src/back/archive.rs +++ b/compiler/rustc_codegen_llvm/src/back/archive.rs @@ -94,10 +94,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> { } } - fn sess(&self) -> &Session { - self.sess - } - fn create_dll_import_lib( sess: &Session, lib_name: &str, diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index d511c340802..4b55085d720 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -1,4 +1,3 @@ -use rustc_data_structures::temp_dir::MaybeTempDir; use rustc_session::cstore::DllImport; use rustc_session::Session; @@ -51,8 +50,6 @@ pub trait ArchiveBuilder<'a> { fn build(self, output: &Path) -> bool; - fn sess(&self) -> &Session; - /// Creates a DLL Import Library <https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-creation#creating-an-import-library>. /// and returns the path on disk to that import library. /// This functions doesn't take `self` so that it can be called from @@ -64,24 +61,4 @@ pub trait ArchiveBuilder<'a> { dll_imports: &[DllImport], tmpdir: &Path, ) -> PathBuf; - - /// Creates a DLL Import Library <https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-creation#creating-an-import-library> - /// and adds it to the current compilation's set of archives. - fn inject_dll_import_lib( - &mut self, - lib_name: &str, - dll_imports: &[DllImport], - tmpdir: &MaybeTempDir, - ) { - let output_path = - Self::create_dll_import_lib(self.sess(), lib_name, dll_imports, tmpdir.as_ref()); - - self.add_archive(&output_path, |_| false).unwrap_or_else(|e| { - self.sess().fatal(&format!( - "failed to add native library {}: {}", - output_path.display(), - e - )); - }); - } } diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index b1d4012474a..b9ad7c94773 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -346,7 +346,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>( for (raw_dylib_name, raw_dylib_imports) in collate_raw_dylibs(sess, &codegen_results.crate_info.used_libraries)? { - ab.inject_dll_import_lib(&raw_dylib_name, &raw_dylib_imports, tmpdir); + let output_path = + B::create_dll_import_lib(sess, &raw_dylib_name, &raw_dylib_imports, tmpdir.as_ref()); + + ab.add_archive(&output_path, |_| false).unwrap_or_else(|e| { + sess.fatal(&format!("failed to add native library {}: {}", output_path.display(), e)); + }); } if let Some(trailing_metadata) = trailing_metadata { |
