about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorDaniel Paoliello <danpao@microsoft.com>2025-04-25 16:44:58 -0700
committerDaniel Paoliello <danpao@microsoft.com>2025-05-07 10:36:12 -0700
commit6dabf7ea3a518a63d273a4d1bcd545ac7d29bd23 (patch)
treed3d81e8d0c11291cf7b7cdb4e1072c79f962582a /compiler/rustc_codegen_llvm/src
parentf5d3fe273b8b9e7125bf8856d44793b6cc4b6735 (diff)
downloadrust-6dabf7ea3a518a63d273a4d1bcd545ac7d29bd23.tar.gz
rust-6dabf7ea3a518a63d273a4d1bcd545ac7d29bd23.zip
[Arm64EC] Only decorate functions with `#`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/consts.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs
index bf81eb648f8..cbac55c7153 100644
--- a/compiler/rustc_codegen_llvm/src/consts.rs
+++ b/compiler/rustc_codegen_llvm/src/consts.rs
@@ -364,7 +364,12 @@ impl<'ll> CodegenCx<'ll, '_> {
 
         if !def_id.is_local() {
             let needs_dll_storage_attr = self.use_dll_storage_attrs
-                && !self.tcx.is_foreign_item(def_id)
+                // If the symbol is a foreign item, then don't automatically apply DLLImport, as
+                // we'll rely on the #[link] attribute instead. BUT, if this is an internal symbol
+                // then it may be generated by the compiler in some crate, so we do need to apply
+                // DLLImport when linking with the MSVC linker.
+                && (!self.tcx.is_foreign_item(def_id)
+                    || (self.sess().target.is_like_msvc && fn_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL)))
                 // Local definitions can never be imported, so we must not apply
                 // the DLLImport annotation.
                 && !dso_local