1
Fork 0

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

This commit is contained in:
Zalathar 2025-01-16 12:53:46 +11:00
parent 419b3e2d3e
commit 2238b00dac
3 changed files with 6 additions and 13 deletions

View file

@ -132,13 +132,6 @@ pub enum LtoCli {
} }
/// The different settings that the `-C instrument-coverage` flag can have. /// The different settings that the `-C instrument-coverage` flag can have.
///
/// Coverage instrumentation now supports combining `-C instrument-coverage`
/// with compiler and linker optimization (enabled with `-O` or `-C opt-level=1`
/// and higher). Nevertheless, there are many variables, depending on options
/// selected, code structure, and enabled attributes. If errors are encountered,
/// either while compiling or when generating `llvm-cov show` reports, consider
/// lowering the optimization level, or including/excluding `-C link-dead-code`.
#[derive(Clone, Copy, PartialEq, Hash, Debug)] #[derive(Clone, Copy, PartialEq, Hash, Debug)]
pub enum InstrumentCoverage { pub enum InstrumentCoverage {
/// `-C instrument-coverage=no` (or `off`, `false` etc.) /// `-C instrument-coverage=no` (or `off`, `false` etc.)

View file

@ -1638,7 +1638,7 @@ options! {
"extra arguments to append to the linker invocation (space separated)"), "extra arguments to append to the linker invocation (space separated)"),
#[rustc_lint_opt_deny_field_access("use `Session::link_dead_code` instead of this field")] #[rustc_lint_opt_deny_field_access("use `Session::link_dead_code` instead of this field")]
link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED], link_dead_code: Option<bool> = (None, parse_opt_bool, [TRACKED],
"keep dead code at link time (useful for code coverage) (default: no)"), "try to generate and link dead code (default: no)"),
link_self_contained: LinkSelfContained = (LinkSelfContained::default(), parse_link_self_contained, [UNTRACKED], link_self_contained: LinkSelfContained = (LinkSelfContained::default(), parse_link_self_contained, [UNTRACKED],
"control whether to link Rust provided C objects/libraries or rely \ "control whether to link Rust provided C objects/libraries or rely \
on a C toolchain or linker installed in the system"), on a C toolchain or linker installed in the system"),

View file

@ -207,14 +207,14 @@ options should be separated by spaces.
## link-dead-code ## link-dead-code
This flag controls whether the linker will keep dead code. It takes one of Tries to generate and link dead code that would otherwise not be generated or
the following values: linked. It takes one of the following values:
* `y`, `yes`, `on`, `true` or no value: keep dead code. * `y`, `yes`, `on`, `true` or no value: try to keep dead code.
* `n`, `no`, `off` or `false`: remove dead code (the default). * `n`, `no`, `off` or `false`: remove dead code (the default).
An example of when this flag might be useful is when trying to construct code coverage This flag was historically used to help improve some older forms of code
metrics. coverage measurement. Its use is not recommended.
## link-self-contained ## link-self-contained