Skip to content

Commit eb34b82

Browse files
committed
Add a new -Z force-full-debuginfo flag
Apparently firefox depends on the current behavior that adds too much debuginfo, but that doesn't mean we need to force it on for rustc itself. Add a new unstable flag for turning it off.
1 parent 13afbda commit eb34b82

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
832832
.unwrap_or_default();
833833
let split_name = split_name.to_str().unwrap();
834834

835-
// FIXME(#60020):
835+
// FIXME(#64405):
836836
//
837837
// This should actually be
838838
//
@@ -847,7 +847,11 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
847847
// the emission kind as `FullDebug`.
848848
//
849849
// See https://github.com/rust-lang/rust/issues/60020 for details.
850-
let kind = DebugEmissionKind::FullDebug;
850+
let kind = if tcx.sess.opts.unstable_opts.force_full_debuginfo {
851+
DebugEmissionKind::FullDebug
852+
} else {
853+
DebugEmissionKind::from_generic(tcx.sess.opts.debuginfo)
854+
};
851855
assert!(tcx.sess.opts.debuginfo != DebugInfo::None);
852856

853857
unsafe {

compiler/rustc_interface/src/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,7 @@ fn test_unstable_options_tracking_hash() {
745745
tracked!(export_executable_symbols, true);
746746
tracked!(fewer_names, Some(true));
747747
tracked!(flatten_format_args, true);
748+
tracked!(force_full_debuginfo, false);
748749
tracked!(force_unstable_if_unmarked, true);
749750
tracked!(fuel, Some(("abc".to_string(), 99)));
750751
tracked!(function_sections, Some(false));

compiler/rustc_session/src/options.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1425,6 +1425,8 @@ options! {
14251425
flatten_format_args: bool = (false, parse_bool, [TRACKED],
14261426
"flatten nested format_args!() and literals into a simplified format_args!() call \
14271427
(default: no)"),
1428+
force_full_debuginfo: bool = (true, parse_bool, [TRACKED],
1429+
"force all codegen-units to have full debuginfo even for -C debuginfo=1. see #64405 (default: yes)"),
14281430
force_unstable_if_unmarked: bool = (false, parse_bool, [TRACKED],
14291431
"force all crates to be `rustc_private` unstable (default: no)"),
14301432
fuel: Option<(String, u64)> = (None, parse_optimization_fuel, [TRACKED],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# `force-full-debuginfo`
2+
3+
The tracking issue for this feature is: [#64405](https://github.com/rust-lang/rust/issues/64405).
4+
5+
---
6+
7+
The option `-Z force-full-debuginfo` controls whether `-C debuginfo=1` generates full debug info for
8+
a codegen-unit. Due to an oversight, debuginfo=1 (which should only mean "line tables") generated
9+
additional debuginfo for many years. Due to backwards compatibility concerns, we are not yet
10+
changing that meaning, but instead adding this flag to allow opting-in to the new, reduced, debuginfo.
11+
12+
Supported options for this value are:
13+
- `yes` - the default, include full debuginfo for the codegen unit
14+
- `no` - include only line info for the codegen unit
15+
16+
The default for this option may change in the future, but it is unlikely to be stabilized.

tests/rustdoc-ui/z-help.stdout

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
-Z extra-const-ub-checks=val -- turns on more checks to detect const UB, which can be slow (default: no)
4646
-Z fewer-names=val -- reduce memory use by retaining fewer names within compilation artifacts (LLVM-IR) (default: no)
4747
-Z flatten-format-args=val -- flatten nested format_args!() and literals into a simplified format_args!() call (default: no)
48+
-Z force-full-debuginfo=val -- force all codegen-units to have full debuginfo even for -C debuginfo=1. see #64405 (default: yes)
4849
-Z force-unstable-if-unmarked=val -- force all crates to be `rustc_private` unstable (default: no)
4950
-Z fuel=val -- set the optimization fuel quota for a crate
5051
-Z function-sections=val -- whether each function should go in its own section

0 commit comments

Comments
 (0)