Move computation of decorated names out of the create_dll_import_lib method
This commit is contained in:
parent
bb764bd406
commit
3c987cbe02
@ -16,7 +16,7 @@ fn create_dll_import_lib(
|
|||||||
&self,
|
&self,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
_lib_name: &str,
|
_lib_name: &str,
|
||||||
_dll_imports: &[rustc_session::cstore::DllImport],
|
_import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||||
_output_path: &Path,
|
_output_path: &Path,
|
||||||
) {
|
) {
|
||||||
sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift");
|
sess.dcx().fatal("raw-dylib is not yet supported by rustc_codegen_cranelift");
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use rustc_codegen_ssa::back::archive::{
|
use rustc_codegen_ssa::back::archive::{
|
||||||
ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
|
ArArchiveBuilder, ArchiveBuilder, ArchiveBuilderBuilder, DEFAULT_OBJECT_READER,
|
||||||
};
|
};
|
||||||
use rustc_session::cstore::DllImport;
|
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
|
||||||
pub(crate) struct ArArchiveBuilderBuilder;
|
pub(crate) struct ArArchiveBuilderBuilder;
|
||||||
@ -17,7 +16,7 @@ fn create_dll_import_lib(
|
|||||||
&self,
|
&self,
|
||||||
_sess: &Session,
|
_sess: &Session,
|
||||||
_lib_name: &str,
|
_lib_name: &str,
|
||||||
_dll_imports: &[DllImport],
|
_import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||||
_output_path: &Path,
|
_output_path: &Path,
|
||||||
) {
|
) {
|
||||||
unimplemented!("creating dll imports is not yet supported");
|
unimplemented!("creating dll imports is not yet supported");
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
ArchiveBuilderBuilder, ObjectReader, UnknownArchiveKind, DEFAULT_OBJECT_READER,
|
ArchiveBuilderBuilder, ObjectReader, UnknownArchiveKind, DEFAULT_OBJECT_READER,
|
||||||
};
|
};
|
||||||
use rustc_codegen_ssa::common;
|
use rustc_codegen_ssa::common;
|
||||||
use rustc_session::cstore::DllImport;
|
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use tracing::trace;
|
use tracing::trace;
|
||||||
|
|
||||||
@ -119,26 +118,12 @@ fn create_dll_import_lib(
|
|||||||
&self,
|
&self,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
lib_name: &str,
|
lib_name: &str,
|
||||||
dll_imports: &[DllImport],
|
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||||
output_path: &Path,
|
output_path: &Path,
|
||||||
) {
|
) {
|
||||||
let target = &sess.target;
|
let target = &sess.target;
|
||||||
let mingw_gnu_toolchain = common::is_mingw_gnu_toolchain(target);
|
let mingw_gnu_toolchain = common::is_mingw_gnu_toolchain(target);
|
||||||
|
|
||||||
let import_name_and_ordinal_vector: Vec<(String, Option<u16>)> = dll_imports
|
|
||||||
.iter()
|
|
||||||
.map(|import: &DllImport| {
|
|
||||||
if sess.target.arch == "x86" {
|
|
||||||
(
|
|
||||||
common::i686_decorated_name(import, mingw_gnu_toolchain, false),
|
|
||||||
import.ordinal(),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(import.name.to_string(), import.ordinal())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
if mingw_gnu_toolchain {
|
if mingw_gnu_toolchain {
|
||||||
// The binutils linker used on -windows-gnu targets cannot read the import
|
// The binutils linker used on -windows-gnu targets cannot read the import
|
||||||
// libraries generated by LLVM: in our attempts, the linker produced an .EXE
|
// libraries generated by LLVM: in our attempts, the linker produced an .EXE
|
||||||
@ -236,9 +221,9 @@ fn create_dll_import_lib(
|
|||||||
trace!(" output_path {}", output_path.display());
|
trace!(" output_path {}", output_path.display());
|
||||||
trace!(
|
trace!(
|
||||||
" import names: {}",
|
" import names: {}",
|
||||||
dll_imports
|
import_name_and_ordinal_vector
|
||||||
.iter()
|
.iter()
|
||||||
.map(|import| import.name.to_string())
|
.map(|(name, _ordinal)| name.clone())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join(", "),
|
.join(", "),
|
||||||
);
|
);
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
use object::read::macho::FatArch;
|
use object::read::macho::FatArch;
|
||||||
use rustc_data_structures::fx::FxIndexSet;
|
use rustc_data_structures::fx::FxIndexSet;
|
||||||
use rustc_data_structures::memmap::Mmap;
|
use rustc_data_structures::memmap::Mmap;
|
||||||
use rustc_session::cstore::DllImport;
|
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
use tempfile::Builder as TempFileBuilder;
|
use tempfile::Builder as TempFileBuilder;
|
||||||
@ -30,7 +29,7 @@ fn create_dll_import_lib(
|
|||||||
&self,
|
&self,
|
||||||
sess: &Session,
|
sess: &Session,
|
||||||
lib_name: &str,
|
lib_name: &str,
|
||||||
dll_imports: &[DllImport],
|
import_name_and_ordinal_vector: Vec<(String, Option<u16>)>,
|
||||||
output_path: &Path,
|
output_path: &Path,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -51,7 +51,8 @@
|
|||||||
use super::metadata::{create_wrapper_file, MetadataPosition};
|
use super::metadata::{create_wrapper_file, MetadataPosition};
|
||||||
use super::rpath::{self, RPathConfig};
|
use super::rpath::{self, RPathConfig};
|
||||||
use crate::{
|
use crate::{
|
||||||
errors, looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo, NativeLib,
|
common, errors, looks_like_rust_object_file, CodegenResults, CompiledModule, CrateInfo,
|
||||||
|
NativeLib,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
|
pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
|
||||||
@ -497,10 +498,26 @@ fn create_dll_import_libs<'a>(
|
|||||||
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
|
let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" };
|
||||||
let output_path = tmpdir.join(format!("{raw_dylib_name}{name_suffix}.lib"));
|
let output_path = tmpdir.join(format!("{raw_dylib_name}{name_suffix}.lib"));
|
||||||
|
|
||||||
|
let mingw_gnu_toolchain = common::is_mingw_gnu_toolchain(&sess.target);
|
||||||
|
|
||||||
|
let import_name_and_ordinal_vector: Vec<(String, Option<u16>)> = raw_dylib_imports
|
||||||
|
.iter()
|
||||||
|
.map(|import: &DllImport| {
|
||||||
|
if sess.target.arch == "x86" {
|
||||||
|
(
|
||||||
|
common::i686_decorated_name(import, mingw_gnu_toolchain, false),
|
||||||
|
import.ordinal(),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
(import.name.to_string(), import.ordinal())
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
|
||||||
archive_builder_builder.create_dll_import_lib(
|
archive_builder_builder.create_dll_import_lib(
|
||||||
sess,
|
sess,
|
||||||
&raw_dylib_name,
|
&raw_dylib_name,
|
||||||
&raw_dylib_imports,
|
import_name_and_ordinal_vector,
|
||||||
&output_path,
|
&output_path,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user