Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unreferenced-used-static: run test everywhere #127115

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

RalfJung
Copy link
Member

Follow-up to #127099.

@rustbot
Copy link
Collaborator

rustbot commented Jun 29, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2024
Copy link
Member

@lqd lqd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me

Comment on lines 1 to 2
// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics in the
// binary crate couldn't be found by the MSVC linker, causing linking errors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of the following?

Suggested change
// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics in the
// binary crate couldn't be found by the MSVC linker, causing linking errors.
// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics
// were forcefully exported and included in the final binary, causing linking errors on MSVC.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They were not included though, wasn't that the issue? If they had been included the linker would not have complained about missing symbols.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the symbol was added to the list of exported symbols.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe just steal #126938 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is also confusing IMO, since "forcing them to be included in the final binary" sounds like what we want.

My understanding is that we are on the one hand telling the linker to export the symbol, but on the other hand the symbol is not actually included in the binary, and that leads to the error. But I may be misunderstanding, this is all very strange to me.

Cc @ChrisDenton

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah basically. As far as I'm aware we don't have any tests that ensure FOO actually ends up in the final binary. It won't, at least on msvc, because we define it as a COMDAT (i.e. we tell the linker it's allowed to remove it).

This is technically in keeping with the documented behaviour which only says the compiler considers it used, and not the linker. But I think that was intended as a hedge and we should still make a best effort to ensure #[used] means it's used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also used(linker) which I guess is meant to tell the linker to keep it -- I don't understand why that is a separate flag though. 🤷

Copy link
Member Author

@RalfJung RalfJung Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the symbol was added to the list of exported symbols.

So what about the current wording?

// This is a non-regression test for issue #127052 where unreferenced `#[used]` statics in the
// binary crate would be marked as "exported", but not be present in the binary, causing linking
// errors with the MSVC linker.

Copy link
Member

@lqd lqd Jul 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whatever Chris prefers, r? @ChrisDenton

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding it a bit hard to summarise without giving a full tutorial on linking. But this explanation seems accurate enough and the issue link helps if anyone wants to explore further. So, yep, this looks good to me.

@fmease fmease assigned lqd and unassigned fmease Jun 30, 2024
@rustbot rustbot assigned ChrisDenton and unassigned lqd Jul 2, 2024
@ChrisDenton
Copy link
Member

@bors r=lqd,ChrisDenton

@bors
Copy link
Contributor

bors commented Jul 3, 2024

📌 Commit cf6f6ca has been approved by lqd,ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 3, 2024
Rollup of 8 pull requests

Successful merges:

 - rust-lang#123588 (Stabilize `hint::assert_unchecked`)
 - rust-lang#126403 (Actually report normalization-based type errors correctly for alias-relate obligations in new solver)
 - rust-lang#126917 (Disable rmake test `inaccessible-temp-dir` on riscv64)
 - rust-lang#127115 (unreferenced-used-static: run test everywhere)
 - rust-lang#127204 (Stabilize atomic_bool_fetch_not)
 - rust-lang#127239 (remove unnecessary ignore-endian-big from stack-overflow-trait-infer …)
 - rust-lang#127245 (Add a test for `generic_const_exprs`)
 - rust-lang#127246 (Give remote-test-client a longer timeout)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 18ec452 into rust-lang:master Jul 3, 2024
6 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jul 3, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jul 3, 2024
Rollup merge of rust-lang#127115 - RalfJung:unreferenced-used-static, r=lqd,ChrisDenton

unreferenced-used-static: run test everywhere

Follow-up to rust-lang#127099.
@RalfJung RalfJung deleted the unreferenced-used-static branch July 5, 2024 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants