Skip to content

Commit 803576c

Browse files
committed
Enable line number debuginfo in releases
This commit enables by default passing the `-C debuginfo=1` argument to the compiler for the stable, beta, and nightly release channels. A new configure option was also added, `--enable-debuginfo-lines`, to enable this behavior in developer builds as well. Closes #36452
1 parent a41505f commit 803576c

File tree

6 files changed

+21
-1
lines changed

6 files changed

+21
-1
lines changed

configure

+8-1
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ opt_nosave optimize-llvm 1 "build optimized LLVM"
636636
opt_nosave llvm-assertions 0 "build LLVM with assertions"
637637
opt_nosave debug-assertions 0 "build with debugging assertions"
638638
opt_nosave debuginfo 0 "build with debugger metadata"
639+
opt_nosave debuginfo-lines 0 "build with line number debugger metadata"
639640
opt_nosave debug-jemalloc 0 "build jemalloc with --enable-debug --enable-fill"
640641

641642
valopt localstatedir "/var/lib" "local state directory"
@@ -721,8 +722,13 @@ case "$CFG_RELEASE_CHANNEL" in
721722
nightly )
722723
msg "overriding settings for $CFG_RELEASE_CHANNEL"
723724
CFG_ENABLE_LLVM_ASSERTIONS=1
725+
CFG_ENABLE_DEBUGINFO_LINES=1
724726
;;
725-
dev | beta | stable)
727+
beta | stable)
728+
msg "overriding settings for $CFG_RELEASE_CHANNEL"
729+
CFG_ENABLE_DEBUGINFO_LINES=1
730+
;;
731+
dev)
726732
;;
727733
*)
728734
err "release channel must be 'dev', 'nightly', 'beta' or 'stable'"
@@ -752,6 +758,7 @@ if [ -n "$CFG_DISABLE_OPTIMIZE_LLVM" ]; then putvar CFG_DISABLE_OPTIMIZE_LLVM; f
752758
if [ -n "$CFG_ENABLE_LLVM_ASSERTIONS" ]; then putvar CFG_ENABLE_LLVM_ASSERTIONS; fi
753759
if [ -n "$CFG_ENABLE_DEBUG_ASSERTIONS" ]; then putvar CFG_ENABLE_DEBUG_ASSERTIONS; fi
754760
if [ -n "$CFG_ENABLE_DEBUGINFO" ]; then putvar CFG_ENABLE_DEBUGINFO; fi
761+
if [ -n "$CFG_ENABLE_DEBUGINFO_LINES" ]; then putvar CFG_ENABLE_DEBUGINFO_LINES; fi
755762
if [ -n "$CFG_ENABLE_DEBUG_JEMALLOC" ]; then putvar CFG_ENABLE_DEBUG_JEMALLOC; fi
756763

757764
step_msg "looking for build programs"

mk/main.mk

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ endif
141141
ifdef CFG_ENABLE_DEBUGINFO
142142
$(info cfg: enabling debuginfo (CFG_ENABLE_DEBUGINFO))
143143
CFG_RUSTC_FLAGS += -g
144+
else ifdef CFG_ENABLE_DEBUGINFO_LINES
145+
$(info cfg: enabling line number debuginfo (CFG_ENABLE_DEBUGINFO_LINES))
146+
CFG_RUSTC_FLAGS += -C debuginfo=1
144147
endif
145148

146149
ifdef SAVE_TEMPS

src/bootstrap/bin/rustc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ fn main() {
112112
// code.
113113
if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) {
114114
cmd.arg("-g");
115+
} else if env::var("RUSTC_DEBUGINFO_LINES") == Ok("true".to_string()) {
116+
cmd.arg("-Cdebuginfo=1");
115117
}
116118
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
117119
Ok(s) => if s == "true" {"y"} else {"n"},

src/bootstrap/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ pub struct Config {
5656
pub rust_codegen_units: u32,
5757
pub rust_debug_assertions: bool,
5858
pub rust_debuginfo: bool,
59+
pub rust_debuginfo_lines: bool,
5960
pub rust_rpath: bool,
6061
pub rustc_default_linker: Option<String>,
6162
pub rustc_default_ar: Option<String>,
@@ -141,6 +142,7 @@ struct Rust {
141142
codegen_units: Option<u32>,
142143
debug_assertions: Option<bool>,
143144
debuginfo: Option<bool>,
145+
debuginfo_lines: Option<bool>,
144146
debug_jemalloc: Option<bool>,
145147
use_jemalloc: Option<bool>,
146148
backtrace: Option<bool>,
@@ -239,6 +241,7 @@ impl Config {
239241
if let Some(ref rust) = toml.rust {
240242
set(&mut config.rust_debug_assertions, rust.debug_assertions);
241243
set(&mut config.rust_debuginfo, rust.debuginfo);
244+
set(&mut config.rust_debuginfo_lines, rust.debuginfo_lines);
242245
set(&mut config.rust_optimize, rust.optimize);
243246
set(&mut config.rust_optimize_tests, rust.optimize_tests);
244247
set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests);
@@ -329,6 +332,7 @@ impl Config {
329332
("OPTIMIZE", self.rust_optimize),
330333
("DEBUG_ASSERTIONS", self.rust_debug_assertions),
331334
("DEBUGINFO", self.rust_debuginfo),
335+
("DEBUGINFO_LINES", self.rust_debuginfo_lines),
332336
("JEMALLOC", self.use_jemalloc),
333337
("DEBUG_JEMALLOC", self.debug_jemalloc),
334338
("RPATH", self.rust_rpath),

src/bootstrap/config.toml.example

+3
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@
9999
# Whether or not debuginfo is emitted
100100
#debuginfo = false
101101

102+
# Whether or not line number debug information is emitted
103+
#debuginfo-lines = false
104+
102105
# Whether or not jemalloc is built and enabled
103106
#use-jemalloc = true
104107

src/bootstrap/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ impl Build {
649649
.env("RUSTC_REAL", self.compiler_path(compiler))
650650
.env("RUSTC_STAGE", stage.to_string())
651651
.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string())
652+
.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string())
652653
.env("RUSTC_CODEGEN_UNITS",
653654
self.config.rust_codegen_units.to_string())
654655
.env("RUSTC_DEBUG_ASSERTIONS",

0 commit comments

Comments
 (0)