Skip to content

Commit

Permalink
Auto merge of rust-lang#127099 - lqd:revert-126938, r=<try>
Browse files Browse the repository at this point in the history
Revert "miri: make sure we can find link_section statics even for the local crate"

This PR reverts rust-lang#126938 as [requested by its author](rust-lang#127052 (comment)), to fix the rust-lang#127052 regression.

r? ghost

fixes rust-lang#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, though this should do for now.

(Opening as draft to run tests on a windows env)

try-job: x86_64-msvc
  • Loading branch information
bors committed Jun 28, 2024
2 parents c4c0897 + 57931e5 commit 6ee8465
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
12 changes: 10 additions & 2 deletions compiler/rustc_passes/src/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use rustc_hir::def_id::{DefId, LocalDefId};
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;
Expand Down Expand Up @@ -178,7 +178,15 @@ impl<'tcx> ReachableContext<'tcx> {
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 {
Expand Down
16 changes: 0 additions & 16 deletions src/tools/miri/tests/pass/tls/win_tls_callback.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/tools/miri/tests/pass/tls/win_tls_callback.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 6ee8465

Please sign in to comment.