1
Fork 0

Inline inject_dll_import_lib

This commit is contained in:
bjorn3 2022-07-28 08:43:15 +00:00
parent 7c93154a30
commit 90da3c6f2b
5 changed files with 6 additions and 36 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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
));
});
}
}

View file

@ -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 {