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

Add a new -Z force-full-debuginfo flag #109311

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
.unwrap_or_default();
let split_name = split_name.to_str().unwrap();

// FIXME(#60020):
// FIXME(#64405):
//
// This should actually be
//
Expand All @@ -847,7 +847,11 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
// the emission kind as `FullDebug`.
//
// See https://github.com/rust-lang/rust/issues/60020 for details.
let kind = DebugEmissionKind::FullDebug;
let kind = if tcx.sess.opts.unstable_opts.force_full_debuginfo {
DebugEmissionKind::FullDebug
} else {
DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo)
};
assert!(tcx.sess.opts.debuginfo != DebugInfo::None);

unsafe {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(export_executable_symbols, true);
tracked!(fewer_names, Some(true));
tracked!(flatten_format_args, true);
tracked!(force_full_debuginfo, false);
tracked!(force_unstable_if_unmarked, true);
tracked!(fuel, Some(("abc".to_string(), 99)));
tracked!(function_sections, Some(false));
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,8 @@ options! {
flatten_format_args: bool = (false, parse_bool, [TRACKED],
"flatten nested format_args!() and literals into a simplified format_args!() call \
(default: no)"),
force_full_debuginfo: bool = (true, parse_bool, [TRACKED],
"force all codegen-units to have full debuginfo even for -C debuginfo=1. see #64405 (default: yes)"),
Copy link
Member

@bjorn3 bjorn3 Mar 19, 2023

Choose a reason for hiding this comment

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

This is not entirely correct. It merely causes more debuginfo to be added, not everything. For example function arguments aren't added to the debuginfo. Just basic things like the linkage name and demangled function name.

force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
"force all crates to be `rustc_private` unstable (default: no)"),
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
Expand Down
16 changes: 16 additions & 0 deletions src/doc/unstable-book/src/compiler-flags/force-full-debuginfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `force-full-debuginfo`

The tracking issue for this feature is: [#64405](https://github.com/rust-lang/rust/issues/64405).

---

The option `-Z force-full-debuginfo` controls whether `-C debuginfo=1` generates full debug info for
a codegen-unit. Due to an oversight, debuginfo=1 (which should only mean "line tables") generated
additional debuginfo for many years. Due to backwards compatibility concerns, we are not yet
changing that meaning, but instead adding this flag to allow opting-in to the new, reduced, debuginfo.

Supported options for this value are:
- `yes` - the default, include full debuginfo for the codegen unit
- `no` - include only line info for the codegen unit

The default for this option may change in the future, but it is unlikely to be stabilized.
1 change: 1 addition & 0 deletions tests/rustdoc-ui/z-help.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
-Z extra-const-ub-checks=val -- turns on more checks to detect const UB, which can be slow (default: no)
-Z fewer-names=val -- reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) (default: no)
-Z flatten-format-args=val -- flatten nested format_args!() and literals into a simplified format_args!() call (default: no)
-Z force-full-debuginfo=val -- force all codegen-units to have full debuginfo even for -C debuginfo=1. see #64405 (default: yes)
-Z force-unstable-if-unmarked=val -- force all crates to be `rustc_private` unstable (default: no)
-Z fuel=val -- set the optimization fuel quota for a crate
-Z function-sections=val -- whether each function should go in its own section
Expand Down