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

Update docs for -Clink-dead-code to discourage its use #135561

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

Zalathar
Copy link
Contributor

The -Clink-dead-code flag was originally added way back in #31368, apparently to help improve the output of some older forms of code coverage measurement, and also to address some use-cases for wanting to suppress linker flags like -dead_strip and --gc-section.

In the past it might have also been useful in conjunction with -Cinstrument-coverage, but subsequent improvements to coverage instrumentation have made it unnecessary there.

It is also currently used by cargo-fuzz by default, for reasons that are possibly no longer relevant.


The flag currently does more than its name suggests, affecting not just linker flags, but also monomorphization decisions. It has also contributed to ICEs (e.g. #135515) that would not have occurred without link-dead-code.


For now, this PR just updates the documentation to be more realistic about what the flag does, and when it should be used (approximately never). In the future, it might be worth looking into properly deprecating this flag, and perhaps making it a no-op if feasible.

@rustbot
Copy link
Collaborator

rustbot commented Jan 16, 2025

r? @Noratrieb

rustbot has assigned @Noratrieb.
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 Jan 16, 2025
@Zalathar
Copy link
Contributor Author

cc @compiler-errors @saethlin

@saethlin
Copy link
Member

I think the change here is pretty uncontroversial, the discouragement is not particularly strong and the other changes are just factually correct. The flag's description has been wrong for many years.

r? saethlin
@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jan 16, 2025

📌 Commit 2238b00 has been approved by saethlin

It is now in the queue for this repository.

@rustbot rustbot assigned saethlin and unassigned Noratrieb Jan 16, 2025
@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 Jan 16, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2025
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#134754 (Implement `use` associated items of traits)
 - rust-lang#135481 (coverage: Completely overhaul counter assignment, using node-flow graphs)
 - rust-lang#135504 (Allow coercing safe-to-call target_feature functions to safe fn pointers)
 - rust-lang#135561 (Update docs for `-Clink-dead-code` to discourage its use)
 - rust-lang#135574 (ci: mirror ubuntu:22.04 to ghcr.io)
 - rust-lang#135585 (resolve symlinks of LLVM tool binaries before copying them)
 - rust-lang#135588 (Add license-metadata.json to rustc-src tarball.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f7e1ae4 into rust-lang:master Jan 17, 2025
6 checks passed
@rustbot rustbot added this to the 1.86.0 milestone Jan 17, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 17, 2025
Rollup merge of rust-lang#135561 - Zalathar:link-dead-code, r=saethlin

Update docs for `-Clink-dead-code` to discourage its use

The `-Clink-dead-code` flag was originally added way back in rust-lang#31368, apparently to help improve the output of some older forms of code coverage measurement, and also to address some use-cases for wanting to suppress linker flags like `-dead_strip` and `--gc-section`.

In the past it might have also been useful in conjunction with `-Cinstrument-coverage`, but subsequent improvements to coverage instrumentation have made it unnecessary there.

[It is also currently used by cargo-fuzz by default](rust-fuzz/cargo-fuzz#391), for reasons that are possibly no longer relevant.

---

The flag currently does more than its name suggests, affecting not just linker flags, but also monomorphization decisions. It has also contributed to ICEs (e.g. rust-lang#135515) that would not have occurred without link-dead-code.

---

For now, this PR just updates the documentation to be more realistic about what the flag does, and when it should be used (approximately never). In the future, it might be worth looking into properly deprecating this flag, and perhaps making it a no-op if feasible.
@Zalathar Zalathar deleted the link-dead-code branch January 17, 2025 01:29
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.

5 participants