Skip to content

Commit 9ed2ab3

Browse files
committed
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](#127052 (comment)), to fix the #127052 regression. Fixes #127052 We should probably improve the [`used` rmake test(s)](https://github.com/rust-lang/rust/blob/57931e50409f9365791f7923a68f9ae1ec301c4c/tests/run-make/used/rmake.rs#L7) in the future, but this should do for now.
2 parents e9e6e2e + 57931e5 commit 9ed2ab3

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

compiler/rustc_passes/src/reachable.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
3030
use rustc_hir::intravisit::{self, Visitor};
3131
use rustc_hir::Node;
3232
use rustc_middle::bug;
33-
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
33+
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
3434
use rustc_middle::middle::privacy::{self, Level};
3535
use rustc_middle::mir::interpret::{ConstAllocation, ErrorHandled, GlobalAlloc};
3636
use rustc_middle::query::Providers;
@@ -178,7 +178,15 @@ impl<'tcx> ReachableContext<'tcx> {
178178
if !self.any_library {
179179
// If we are building an executable, only explicitly extern
180180
// types need to be exported.
181-
if has_custom_linkage(self.tcx, search_item) {
181+
let codegen_attrs = if self.tcx.def_kind(search_item).has_codegen_attrs() {
182+
self.tcx.codegen_fn_attrs(search_item)
183+
} else {
184+
CodegenFnAttrs::EMPTY
185+
};
186+
let is_extern = codegen_attrs.contains_extern_indicator();
187+
let std_internal =
188+
codegen_attrs.flags.contains(CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL);
189+
if is_extern || std_internal {
182190
self.reachable_symbols.insert(search_item);
183191
}
184192
} else {

src/tools/miri/tests/pass/tls/win_tls_callback.rs

-16
This file was deleted.

src/tools/miri/tests/pass/tls/win_tls_callback.stderr

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics couldn't be
2+
// removed by the MSVC linker, causing linking errors.
3+
4+
//@ build-pass: needs linking
5+
//@ only-msvc
6+
7+
#[used]
8+
static FOO: u32 = 0;
9+
fn main() {}

0 commit comments

Comments
 (0)