Rollup merge of #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 #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](https://github.com/rust-fuzz/cargo-fuzz/issues/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. #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.
This commit is contained in:
commit
f7e1ae40f5
3 changed files with 6 additions and 13 deletions
|
@ -132,13 +132,6 @@ pub enum LtoCli {
|
|||
}
|
||||
|
||||
/// 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)]
|
||||
pub enum InstrumentCoverage {
|
||||
/// `-C instrument-coverage=no` (or `off`, `false` etc.)
|
||||
|
|
|
@ -1638,7 +1638,7 @@ options! {
|
|||
"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")]
|
||||
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],
|
||||
"control whether to link Rust provided C objects/libraries or rely \
|
||||
on a C toolchain or linker installed in the system"),
|
||||
|
|
|
@ -207,14 +207,14 @@ options should be separated by spaces.
|
|||
|
||||
## link-dead-code
|
||||
|
||||
This flag controls whether the linker will keep dead code. It takes one of
|
||||
the following values:
|
||||
Tries to generate and link dead code that would otherwise not be generated or
|
||||
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).
|
||||
|
||||
An example of when this flag might be useful is when trying to construct code coverage
|
||||
metrics.
|
||||
This flag was historically used to help improve some older forms of code
|
||||
coverage measurement. Its use is not recommended.
|
||||
|
||||
## link-self-contained
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue