Skip to content

Commit 34ee31d

Browse files
committed
Rollup merge of rust-lang#49959 - cuviper:debuginfo-tools, r=Mark-Simulacrum
rustbuild: allow building tools with debuginfo Debugging information for the extended tools is currently disabled for concerns about the size. This patch adds `--enable-debuginfo-tools` to let one opt into having that debuginfo. This is useful for debugging the tools in distro packages. We always strip debuginfo into separate packages anyway, so the extra size is not a concern in regular use.
2 parents 73ea893 + 93734e9 commit 34ee31d

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ configuration used in the build process. Some options to note:
121121
#### `[rust]`:
122122
- `debuginfo = true` - Build a compiler with debuginfo. Makes building rustc slower, but then you can use a debugger to debug `rustc`.
123123
- `debuginfo-lines = true` - An alternative to `debuginfo = true` that doesn't let you use a debugger, but doesn't make building rustc slower and still gives you line numbers in backtraces.
124+
- `debuginfo-tools = true` - Build the extended tools with debuginfo.
124125
- `debug-assertions = true` - Makes the log output of `debug!` work.
125126
- `optimize = false` - Disable optimizations to speed up compilation of stage1 rust, but makes the stage1 compiler x100 slower.
126127

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,10 @@
262262
# standard library.
263263
#debuginfo-only-std = false
264264

265+
# Enable debuginfo for the extended tools: cargo, rls, rustfmt
266+
# Adding debuginfo makes them several times larger.
267+
#debuginfo-tools = false
268+
265269
# Whether or not jemalloc is built and enabled
266270
#use-jemalloc = true
267271

src/bootstrap/builder.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,14 @@ impl<'a> Builder<'a> {
622622
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(self.compiler(2, self.build.build)));
623623
}
624624

625-
if mode != Mode::Tool {
626-
// Tools don't get debuginfo right now, e.g. cargo and rls don't
627-
// get compiled with debuginfo.
628-
// Adding debuginfo increases their sizes by a factor of 3-4.
625+
if mode == Mode::Tool {
626+
// Tools like cargo and rls don't get debuginfo by default right now, but this can be
627+
// enabled in the config. Adding debuginfo makes them several times larger.
628+
if self.config.rust_debuginfo_tools {
629+
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
630+
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
631+
}
632+
} else {
629633
cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string());
630634
cargo.env("RUSTC_DEBUGINFO_LINES", self.config.rust_debuginfo_lines.to_string());
631635
cargo.env("RUSTC_FORCE_UNSTABLE", "1");

src/bootstrap/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub struct Config {
9494
pub rust_debuginfo: bool,
9595
pub rust_debuginfo_lines: bool,
9696
pub rust_debuginfo_only_std: bool,
97+
pub rust_debuginfo_tools: bool,
9798
pub rust_rpath: bool,
9899
pub rustc_parallel_queries: bool,
99100
pub rustc_default_linker: Option<String>,
@@ -282,6 +283,7 @@ struct Rust {
282283
debuginfo: Option<bool>,
283284
debuginfo_lines: Option<bool>,
284285
debuginfo_only_std: Option<bool>,
286+
debuginfo_tools: Option<bool>,
285287
experimental_parallel_queries: Option<bool>,
286288
debug_jemalloc: Option<bool>,
287289
use_jemalloc: Option<bool>,
@@ -462,6 +464,7 @@ impl Config {
462464
let mut llvm_assertions = None;
463465
let mut debuginfo_lines = None;
464466
let mut debuginfo_only_std = None;
467+
let mut debuginfo_tools = None;
465468
let mut debug = None;
466469
let mut debug_jemalloc = None;
467470
let mut debuginfo = None;
@@ -499,6 +502,7 @@ impl Config {
499502
debuginfo = rust.debuginfo;
500503
debuginfo_lines = rust.debuginfo_lines;
501504
debuginfo_only_std = rust.debuginfo_only_std;
505+
debuginfo_tools = rust.debuginfo_tools;
502506
optimize = rust.optimize;
503507
ignore_git = rust.ignore_git;
504508
debug_jemalloc = rust.debug_jemalloc;
@@ -582,6 +586,7 @@ impl Config {
582586
};
583587
config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default);
584588
config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default);
589+
config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false);
585590

586591
let default = debug == Some(true);
587592
config.debug_jemalloc = debug_jemalloc.unwrap_or(default);

src/bootstrap/configure.py

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def v(*args):
7979
o("debuginfo", "rust.debuginfo", "build with debugger metadata")
8080
o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata")
8181
o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information")
82+
o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information")
8283
o("debug-jemalloc", "rust.debug-jemalloc", "build jemalloc with --enable-debug --enable-fill")
8384
v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file")
8485

0 commit comments

Comments
 (0)