diff options
| author | The Miri Cronjob Bot <miri@cron.bot> | 2025-05-10 05:01:09 +0000 |
|---|---|---|
| committer | The Miri Cronjob Bot <miri@cron.bot> | 2025-05-10 05:01:09 +0000 |
| commit | a4f765dcada7c37abfc3beda66b7823736b58ea6 (patch) | |
| tree | b815913f2d6c42de19b550fd5f5941555789ab08 /compiler/rustc_codegen_llvm/src/consts.rs | |
| parent | 6e5d6473aaa21d6fae3eb7afdacdfaf93391bfc7 (diff) | |
| parent | 35679bad981e1551138a8b367c0571b0a5928a27 (diff) | |
| download | rust-a4f765dcada7c37abfc3beda66b7823736b58ea6.tar.gz rust-a4f765dcada7c37abfc3beda66b7823736b58ea6.zip | |
Merge from rustc
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/consts.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 7 |
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 |
