Skip to content

Commit 90da3c6

Browse files
committed
Inline inject_dll_import_lib
1 parent 7c93154 commit 90da3c6

File tree

5 files changed

+6
-36
lines changed

5 files changed

+6
-36
lines changed

compiler/rustc_codegen_cranelift/src/archive.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
219219
any_members
220220
}
221221

222-
fn sess(&self) -> &Session {
223-
self.sess
224-
}
225-
226222
fn create_dll_import_lib(
227223
_sess: &Session,
228224
_lib_name: &str,

compiler/rustc_codegen_gcc/src/archive.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
172172
any_members
173173
}
174174

175-
fn sess(&self) -> &Session {
176-
self.config.sess
177-
}
178-
179175
fn create_dll_import_lib(
180176
_sess: &Session,
181177
_lib_name: &str,

compiler/rustc_codegen_llvm/src/back/archive.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
9494
}
9595
}
9696

97-
fn sess(&self) -> &Session {
98-
self.sess
99-
}
100-
10197
fn create_dll_import_lib(
10298
sess: &Session,
10399
lib_name: &str,

compiler/rustc_codegen_ssa/src/back/archive.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use rustc_data_structures::temp_dir::MaybeTempDir;
21
use rustc_session::cstore::DllImport;
32
use rustc_session::Session;
43

@@ -51,8 +50,6 @@ pub trait ArchiveBuilder<'a> {
5150

5251
fn build(self, output: &Path) -> bool;
5352

54-
fn sess(&self) -> &Session;
55-
5653
/// Creates a DLL Import Library <https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-creation#creating-an-import-library>.
5754
/// and returns the path on disk to that import library.
5855
/// This functions doesn't take `self` so that it can be called from
@@ -64,24 +61,4 @@ pub trait ArchiveBuilder<'a> {
6461
dll_imports: &[DllImport],
6562
tmpdir: &Path,
6663
) -> PathBuf;
67-
68-
/// Creates a DLL Import Library <https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-creation#creating-an-import-library>
69-
/// and adds it to the current compilation's set of archives.
70-
fn inject_dll_import_lib(
71-
&mut self,
72-
lib_name: &str,
73-
dll_imports: &[DllImport],
74-
tmpdir: &MaybeTempDir,
75-
) {
76-
let output_path =
77-
Self::create_dll_import_lib(self.sess(), lib_name, dll_imports, tmpdir.as_ref());
78-
79-
self.add_archive(&output_path, |_| false).unwrap_or_else(|e| {
80-
self.sess().fatal(&format!(
81-
"failed to add native library {}: {}",
82-
output_path.display(),
83-
e
84-
));
85-
});
86-
}
8764
}

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,12 @@ fn link_rlib<'a, B: ArchiveBuilder<'a>>(
346346
for (raw_dylib_name, raw_dylib_imports) in
347347
collate_raw_dylibs(sess, &codegen_results.crate_info.used_libraries)?
348348
{
349-
ab.inject_dll_import_lib(&raw_dylib_name, &raw_dylib_imports, tmpdir);
349+
let output_path =
350+
B::create_dll_import_lib(sess, &raw_dylib_name, &raw_dylib_imports, tmpdir.as_ref());
351+
352+
ab.add_archive(&output_path, |_| false).unwrap_or_else(|e| {
353+
sess.fatal(&format!("failed to add native library {}: {}", output_path.display(), e));
354+
});
350355
}
351356

352357
if let Some(trailing_metadata) = trailing_metadata {

0 commit comments

Comments
 (0)