diff options
| author | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-07-25 20:08:40 +0000 |
|---|---|---|
| committer | bjorn3 <17426603+bjorn3@users.noreply.github.com> | 2024-07-30 10:32:32 +0000 |
| commit | 3c987cbe0284a954f025546e53b7007ae1cc95f1 (patch) | |
| tree | 7ab9b43197c1f5976199c41d720c0362fa46a899 /compiler/rustc_codegen_ssa/src | |
| parent | bb764bd406fbfbbd24ac162a1c9d10d349b5e386 (diff) | |
| download | rust-3c987cbe0284a954f025546e53b7007ae1cc95f1.tar.gz rust-3c987cbe0284a954f025546e53b7007ae1cc95f1.zip | |
Move computation of decorated names out of the create_dll_import_lib method
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/archive.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/back/link.rs | 21 |
2 files changed, 20 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/archive.rs b/compiler/rustc_codegen_ssa/src/back/archive.rs index b4ee6514b04..0429f11f9ff 100644 --- a/compiler/rustc_codegen_ssa/src/back/archive.rs +++ b/compiler/rustc_codegen_ssa/src/back/archive.rs @@ -9,7 +9,6 @@ use object::read::archive::ArchiveFile; use object::read::macho::FatArch; use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::memmap::Mmap; -use rustc_session::cstore::DllImport; use rustc_session::Session; use rustc_span::symbol::Symbol; use tempfile::Builder as TempFileBuilder; @@ -30,7 +29,7 @@ pub trait ArchiveBuilderBuilder { &self, sess: &Session, lib_name: &str, - dll_imports: &[DllImport], + import_name_and_ordinal_vector: Vec<(String, Option<u16>)>, output_path: &Path, ); diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 4bdaeaf2996..e6bd0e3d4f7 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -51,7 +51,8 @@ use super::linker::{self, Linker}; use super::metadata::{create_wrapper_file, MetadataPosition}; use super::rpath::{self, RPathConfig}; 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) { @@ -497,10 +498,26 @@ fn create_dll_import_libs<'a>( let name_suffix = if is_direct_dependency { "_imports" } else { "_imports_indirect" }; 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( sess, &raw_dylib_name, - &raw_dylib_imports, + import_name_and_ordinal_vector, &output_path, ); |
