Auto merge of #127099 - lqd:revert-126938, r=compiler-errors
Revert "miri: make sure we can find link_section statics even for the local crate"
This PR reverts #126938 as [requested by its author](https://github.com/rust-lang/rust/issues/127052#issuecomment-2196793473), to fix the #127052 regression.
Fixes #127052
We should probably improve the [`used` rmake test(s)](57931e5040/tests/run-make/used/rmake.rs (L7)
) in the future, but this should do for now.
This commit is contained in:
commit
9ed2ab3790
@ -30,7 +30,7 @@
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::Node;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
|
||||
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
|
||||
use rustc_middle::middle::privacy::{self, Level};
|
||||
use rustc_middle::mir::interpret::{ConstAllocation, ErrorHandled, GlobalAlloc};
|
||||
use rustc_middle::query::Providers;
|
||||
@ -178,7 +178,15 @@ fn propagate_node(&mut self, node: &Node<'tcx>, search_item: LocalDefId) {
|
||||
if !self.any_library {
|
||||
// If we are building an executable, only explicitly extern
|
||||
// types need to be exported.
|
||||
if has_custom_linkage(self.tcx, search_item) {
|
||||
let codegen_attrs = if self.tcx.def_kind(search_item).has_codegen_attrs() {
|
||||
self.tcx.codegen_fn_attrs(search_item)
|
||||
} else {
|
||||
CodegenFnAttrs::EMPTY
|
||||
};
|
||||
let is_extern = codegen_attrs.contains_extern_indicator();
|
||||
let std_internal =
|
||||
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
|
||||
if is_extern || std_internal {
|
||||
self.reachable_symbols.insert(search_item);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,16 +0,0 @@
|
||||
//! Ensure that we call Windows TLS callbacks in the local crate.
|
||||
//@only-target-windows
|
||||
// Calling eprintln in the callback seems to (re-)initialize some thread-local storage
|
||||
// and then leak the memory allocated for that. Let's just ignore these leaks,
|
||||
// that's not what this test is about.
|
||||
//@compile-flags: -Zmiri-ignore-leaks
|
||||
|
||||
#[link_section = ".CRT$XLB"]
|
||||
#[used] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
|
||||
pub static CALLBACK: unsafe extern "system" fn(*const (), u32, *const ()) = tls_callback;
|
||||
|
||||
unsafe extern "system" fn tls_callback(_h: *const (), _dw_reason: u32, _pv: *const ()) {
|
||||
eprintln!("in tls_callback");
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -1 +0,0 @@
|
||||
in tls_callback
|
@ -0,0 +1,9 @@
|
||||
// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics couldn't be
|
||||
// removed by the MSVC linker, causing linking errors.
|
||||
|
||||
//@ build-pass: needs linking
|
||||
//@ only-msvc
|
||||
|
||||
#[used]
|
||||
static FOO: u32 = 0;
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user