Skip to content

Commit c1f2da5

Browse files
authored
Rollup merge of rust-lang#112528 - jyn514:fix-debuginfo-level, r=Mark-Simulacrum
bootstrap: Don't override `debuginfo-level = 1` to mean `line-tables-only` This has real differences in the effective debuginfo: in particular, it omits the module-level information and makes perf less useful (it can't distinguish "self" from "child" time anymore). Allow passing `line-tables-only` directly in config.toml instead. See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/debuginfo.20in.20try.20builds/near/365090631 and https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bsteering.5D.202023-06-09/near/364883519 for more discussion. This effectively reverts the cargo half of rust-lang#110221 to avoid regressing rust-lang#60020 again in 1.72.
2 parents d9ae718 + 1236939 commit c1f2da5

File tree

2 files changed

+73
-20
lines changed

2 files changed

+73
-20
lines changed

src/bootstrap/builder.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1649,12 +1649,7 @@ impl<'a> Builder<'a> {
16491649
self.config.rust_debuginfo_level_tools
16501650
}
16511651
};
1652-
if debuginfo_level == 1 {
1653-
// Use less debuginfo than the default to save on disk space.
1654-
cargo.env(profile_var("DEBUG"), "line-tables-only");
1655-
} else {
1656-
cargo.env(profile_var("DEBUG"), debuginfo_level.to_string());
1657-
};
1652+
cargo.env(profile_var("DEBUG"), debuginfo_level.to_string());
16581653
if self.cc[&target].args().iter().any(|arg| arg == "-gz") {
16591654
rustflags.arg("-Clink-arg=-gz");
16601655
}

src/bootstrap/config.rs

+72-14
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::cell::{Cell, RefCell};
1010
use std::cmp;
1111
use std::collections::{HashMap, HashSet};
1212
use std::env;
13-
use std::fmt;
13+
use std::fmt::{self, Display};
1414
use std::fs;
1515
use std::io::IsTerminal;
1616
use std::path::{Path, PathBuf};
@@ -50,6 +50,57 @@ pub enum DryRun {
5050
UserSelected,
5151
}
5252

53+
#[derive(Copy, Clone, Default)]
54+
pub enum DebuginfoLevel {
55+
#[default]
56+
None,
57+
LineTablesOnly,
58+
Limited,
59+
Full,
60+
}
61+
62+
// NOTE: can't derive(Deserialize) because the intermediate trip through toml::Value only
63+
// deserializes i64, and derive() only generates visit_u64
64+
impl<'de> Deserialize<'de> for DebuginfoLevel {
65+
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
66+
where
67+
D: Deserializer<'de>,
68+
{
69+
use serde::de::Error;
70+
71+
Ok(match Deserialize::deserialize(deserializer)? {
72+
StringOrInt::String("none") | StringOrInt::Int(0) => DebuginfoLevel::None,
73+
StringOrInt::String("line-tables-only") => DebuginfoLevel::LineTablesOnly,
74+
StringOrInt::String("limited") | StringOrInt::Int(1) => DebuginfoLevel::Limited,
75+
StringOrInt::String("full") | StringOrInt::Int(2) => DebuginfoLevel::Full,
76+
StringOrInt::Int(n) => {
77+
let other = serde::de::Unexpected::Signed(n);
78+
return Err(D::Error::invalid_value(other, &"expected 0, 1, or 2"));
79+
}
80+
StringOrInt::String(s) => {
81+
let other = serde::de::Unexpected::Str(s);
82+
return Err(D::Error::invalid_value(
83+
other,
84+
&"expected none, line-tables-only, limited, or full",
85+
));
86+
}
87+
})
88+
}
89+
}
90+
91+
/// Suitable for passing to `-C debuginfo`
92+
impl Display for DebuginfoLevel {
93+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
94+
use DebuginfoLevel::*;
95+
f.write_str(match self {
96+
None => "0",
97+
LineTablesOnly => "line-tables-only",
98+
Limited => "1",
99+
Full => "2",
100+
})
101+
}
102+
}
103+
53104
/// Global configuration for the entire build and/or bootstrap.
54105
///
55106
/// This structure is parsed from `config.toml`, and some of the fields are inferred from `git` or build-time parameters.
@@ -159,10 +210,10 @@ pub struct Config {
159210
pub rust_overflow_checks: bool,
160211
pub rust_overflow_checks_std: bool,
161212
pub rust_debug_logging: bool,
162-
pub rust_debuginfo_level_rustc: u32,
163-
pub rust_debuginfo_level_std: u32,
164-
pub rust_debuginfo_level_tools: u32,
165-
pub rust_debuginfo_level_tests: u32,
213+
pub rust_debuginfo_level_rustc: DebuginfoLevel,
214+
pub rust_debuginfo_level_std: DebuginfoLevel,
215+
pub rust_debuginfo_level_tools: DebuginfoLevel,
216+
pub rust_debuginfo_level_tests: DebuginfoLevel,
166217
pub rust_split_debuginfo: SplitDebuginfo,
167218
pub rust_rpath: bool,
168219
pub rustc_parallel: bool,
@@ -810,6 +861,13 @@ impl Default for StringOrBool {
810861
}
811862
}
812863

864+
#[derive(Deserialize)]
865+
#[serde(untagged)]
866+
enum StringOrInt<'a> {
867+
String(&'a str),
868+
Int(i64),
869+
}
870+
813871
define_config! {
814872
/// TOML representation of how the Rust build is configured.
815873
struct Rust {
@@ -822,11 +880,11 @@ define_config! {
822880
overflow_checks: Option<bool> = "overflow-checks",
823881
overflow_checks_std: Option<bool> = "overflow-checks-std",
824882
debug_logging: Option<bool> = "debug-logging",
825-
debuginfo_level: Option<u32> = "debuginfo-level",
826-
debuginfo_level_rustc: Option<u32> = "debuginfo-level-rustc",
827-
debuginfo_level_std: Option<u32> = "debuginfo-level-std",
828-
debuginfo_level_tools: Option<u32> = "debuginfo-level-tools",
829-
debuginfo_level_tests: Option<u32> = "debuginfo-level-tests",
883+
debuginfo_level: Option<DebuginfoLevel> = "debuginfo-level",
884+
debuginfo_level_rustc: Option<DebuginfoLevel> = "debuginfo-level-rustc",
885+
debuginfo_level_std: Option<DebuginfoLevel> = "debuginfo-level-std",
886+
debuginfo_level_tools: Option<DebuginfoLevel> = "debuginfo-level-tools",
887+
debuginfo_level_tests: Option<DebuginfoLevel> = "debuginfo-level-tests",
830888
split_debuginfo: Option<String> = "split-debuginfo",
831889
run_dsymutil: Option<bool> = "run-dsymutil",
832890
backtrace: Option<bool> = "backtrace",
@@ -1478,17 +1536,17 @@ impl Config {
14781536

14791537
config.rust_debug_logging = debug_logging.unwrap_or(config.rust_debug_assertions);
14801538

1481-
let with_defaults = |debuginfo_level_specific: Option<u32>| {
1539+
let with_defaults = |debuginfo_level_specific: Option<_>| {
14821540
debuginfo_level_specific.or(debuginfo_level).unwrap_or(if debug == Some(true) {
1483-
1
1541+
DebuginfoLevel::Limited
14841542
} else {
1485-
0
1543+
DebuginfoLevel::None
14861544
})
14871545
};
14881546
config.rust_debuginfo_level_rustc = with_defaults(debuginfo_level_rustc);
14891547
config.rust_debuginfo_level_std = with_defaults(debuginfo_level_std);
14901548
config.rust_debuginfo_level_tools = with_defaults(debuginfo_level_tools);
1491-
config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(0);
1549+
config.rust_debuginfo_level_tests = debuginfo_level_tests.unwrap_or(DebuginfoLevel::None);
14921550

14931551
let download_rustc = config.download_rustc_commit.is_some();
14941552
// See https://github.com/rust-lang/compiler-team/issues/326

0 commit comments

Comments
 (0)