Skip to content

Commit 12915ad

Browse files
committed
Include line numbers in debuginfo by default for developers
- Set the default to LineTablesOnly. This isn't enough debuginfo to run perf, but it's enough to get full backtraces. - Don't build debuginfo for build scripts and proc macros. This lowers the total disk space for stage0-rustc from 5.4 to 5.3 GB, or by 120 MB. - Fix a bug in deserialization where string values would never be deserialized For reasons I don't quite understand, using `&str` unconditionally failed: ``` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { inner: Error { inner: TomlError { message: "data did not match any variant of untagged enum StringOrInt", original: None, keys: [], span: None } } }', src/main.rs:15:49 ```
1 parent 1d67eba commit 12915ad

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

src/bootstrap/builder.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1650,6 +1650,8 @@ impl<'a> Builder<'a> {
16501650
}
16511651
};
16521652
cargo.env(profile_var("DEBUG"), debuginfo_level.to_string());
1653+
// Regardless of the config setting, don't build debuginfo for build scripts.
1654+
cargo.env(profile_var("BUILD_OVERRIDE_DEBUG"), "0");
16531655
if !self.config.dry_run() && self.cc.borrow()[&target].args().iter().any(|arg| arg == "-gz")
16541656
{
16551657
rustflags.arg("-Clink-arg=-gz");

src/bootstrap/config.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,25 @@ impl<'de> Deserialize<'de> for DebuginfoLevel {
6969
use serde::de::Error;
7070

7171
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,
72+
StringOrInt::Int(0) => DebuginfoLevel::None,
73+
StringOrInt::Int(1) => DebuginfoLevel::Limited,
74+
StringOrInt::Int(2) => DebuginfoLevel::Full,
7675
StringOrInt::Int(n) => {
7776
let other = serde::de::Unexpected::Signed(n);
7877
return Err(D::Error::invalid_value(other, &"expected 0, 1, or 2"));
7978
}
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-
}
79+
StringOrInt::String(s) => match s.as_str() {
80+
"none" => DebuginfoLevel::None,
81+
"line-tables-only" => DebuginfoLevel::LineTablesOnly,
82+
"limited" => DebuginfoLevel::Limited,
83+
"full" => DebuginfoLevel::Full,
84+
_ => {
85+
return Err(D::Error::invalid_value(
86+
serde::de::Unexpected::Str(&s),
87+
&"expected none, line-tables-only, limited, or full",
88+
));
89+
}
90+
},
8791
})
8892
}
8993
}
@@ -877,8 +881,8 @@ impl Default for StringOrBool {
877881

878882
#[derive(Deserialize)]
879883
#[serde(untagged)]
880-
enum StringOrInt<'a> {
881-
String(&'a str),
884+
enum StringOrInt {
885+
String(String),
882886
Int(i64),
883887
}
884888

src/bootstrap/defaults/config.codegen.toml

+2
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ incremental = true
2323
backtrace-on-ice = true
2424
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
2525
lto = "off"
26+
# Include line numbers in backtraces.
27+
debuginfo-level-rustc = "line-tables-only"

src/bootstrap/defaults/config.compiler.toml

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ incremental = true
1414
backtrace-on-ice = true
1515
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1616
lto = "off"
17+
# Include line numbers in backtraces.
18+
debuginfo-level-rustc = "line-tables-only"
1719

1820
[llvm]
1921
# Will download LLVM from CI if available on your platform.

src/bootstrap/defaults/config.library.toml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ bench-stage = 0
1010
incremental = true
1111
# Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
1212
lto = "off"
13+
# Include line numbers in backtraces.
14+
debuginfo-level-std = "line-tables-only"
1315

1416
[llvm]
1517
# Will download LLVM from CI if available on your platform.

src/bootstrap/defaults/config.tools.toml

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ incremental = true
1212
# Using these defaults will download the stage2 compiler (see `download-rustc`
1313
# setting) and the stage2 toolchain should therefore be used for these defaults.
1414
download-rustc = "if-unchanged"
15+
# Include line numbers in backtraces.
16+
debuginfo-level-tools = "line-tables-only"
1517

1618
[build]
1719
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.

0 commit comments

Comments
 (0)