diff options
| author | bors <bors@rust-lang.org> | 2024-08-07 14:10:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-08-07 14:10:46 +0000 |
| commit | 8d0066922b14cee3175e8c141e5e909fa6d9a6eb (patch) | |
| tree | 30c9da0e9f2be154bbce28f6c9dc50f3d2cdcdbd /compiler/rustc_codegen_llvm/src/common.rs | |
| parent | 9bad7ba324099d124c77c5b06aebf68e11763f7b (diff) | |
| parent | 920cb642a4708e52e6b92f39f224cb5c855b8cec (diff) | |
| download | rust-8d0066922b14cee3175e8c141e5e909fa6d9a6eb.tar.gz rust-8d0066922b14cee3175e8c141e5e909fa6d9a6eb.zip | |
Auto merge of #128783 - GuillaumeGomez:rollup-2kvpg7s, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - #128206 (Make create_dll_import_lib easier to implement) - #128424 (minor `effects` cleanups) - #128527 (More information for fully-qualified suggestion when there are multiple impls) - #128656 (Enable msvc for run-make/rust-lld) - #128683 (bootstrap: clear miri's ui test deps when rustc changes) - #128700 (Migrate `simd-ffi` `run-make` test to rmake) - #128753 (Don't arbitrarily choose one upper bound for hidden captured region error message) - #128757 (Migrate `pgo-gen-lto` `run-make` test to rmake) - #128758 (Specify a minimum supported version for VxWorks) Failed merges: - #128679 (codegen: better centralize function declaration attribute computation) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/common.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/common.rs | 66 |
1 files changed, 1 insertions, 65 deletions
diff --git a/compiler/rustc_codegen_llvm/src/common.rs b/compiler/rustc_codegen_llvm/src/common.rs index 197bbb9ddbf..65f974c5689 100644 --- a/compiler/rustc_codegen_llvm/src/common.rs +++ b/compiler/rustc_codegen_llvm/src/common.rs @@ -1,7 +1,5 @@ //! Code that is useful in various codegen modules. -use std::fmt::Write; - use libc::{c_char, c_uint}; use rustc_ast::Mutability; use rustc_codegen_ssa::traits::*; @@ -10,9 +8,8 @@ use rustc_hir::def_id::DefId; use rustc_middle::bug; use rustc_middle::mir::interpret::{ConstAllocation, GlobalAlloc, Scalar}; use rustc_middle::ty::TyCtxt; -use rustc_session::cstore::{DllCallingConvention, DllImport, PeImportNameType}; +use rustc_session::cstore::DllImport; use rustc_target::abi::{self, AddressSpace, HasDataLayout, Pointer}; -use rustc_target::spec::Target; use tracing::debug; use crate::consts::const_alloc_to_llvm; @@ -379,64 +376,3 @@ pub(crate) fn get_dllimport<'tcx>( tcx.native_library(id) .and_then(|lib| lib.dll_imports.iter().find(|di| di.name.as_str() == name)) } - -pub(crate) fn is_mingw_gnu_toolchain(target: &Target) -> bool { - target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty() -} - -pub(crate) fn i686_decorated_name( - dll_import: &DllImport, - mingw: bool, - disable_name_mangling: bool, -) -> String { - let name = dll_import.name.as_str(); - - let (add_prefix, add_suffix) = match dll_import.import_name_type { - Some(PeImportNameType::NoPrefix) => (false, true), - Some(PeImportNameType::Undecorated) => (false, false), - _ => (true, true), - }; - - // Worst case: +1 for disable name mangling, +1 for prefix, +4 for suffix (@@__). - let mut decorated_name = String::with_capacity(name.len() + 6); - - if disable_name_mangling { - // LLVM uses a binary 1 ('\x01') prefix to a name to indicate that mangling needs to be disabled. - decorated_name.push('\x01'); - } - - let prefix = if add_prefix && dll_import.is_fn { - match dll_import.calling_convention { - DllCallingConvention::C | DllCallingConvention::Vectorcall(_) => None, - DllCallingConvention::Stdcall(_) => (!mingw - || dll_import.import_name_type == Some(PeImportNameType::Decorated)) - .then_some('_'), - DllCallingConvention::Fastcall(_) => Some('@'), - } - } else if !dll_import.is_fn && !mingw { - // For static variables, prefix with '_' on MSVC. - Some('_') - } else { - None - }; - if let Some(prefix) = prefix { - decorated_name.push(prefix); - } - - decorated_name.push_str(name); - - if add_suffix && dll_import.is_fn { - match dll_import.calling_convention { - DllCallingConvention::C => {} - DllCallingConvention::Stdcall(arg_list_size) - | DllCallingConvention::Fastcall(arg_list_size) => { - write!(&mut decorated_name, "@{arg_list_size}").unwrap(); - } - DllCallingConvention::Vectorcall(arg_list_size) => { - write!(&mut decorated_name, "@@{arg_list_size}").unwrap(); - } - } - } - - decorated_name -} |
