From 3ea7cf538367f77b79bd81414862ade23d27aaf5 Mon Sep 17 00:00:00 2001 From: klensy Date: Tue, 2 Apr 2024 16:33:51 +0300 Subject: [PATCH 1/2] bootstrap: actually allow set debuginfo-level to "lines-tables-only" --- src/bootstrap/src/core/config/config.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index a272d8bff005d..38bf4718b5a9b 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -70,16 +70,19 @@ impl<'de> Deserialize<'de> for DebuginfoLevel { use serde::de::Error; Ok(match Deserialize::deserialize(deserializer)? { - StringOrInt::String("none") | StringOrInt::Int(0) => DebuginfoLevel::None, - StringOrInt::String("line-tables-only") => DebuginfoLevel::LineTablesOnly, - StringOrInt::String("limited") | StringOrInt::Int(1) => DebuginfoLevel::Limited, - StringOrInt::String("full") | StringOrInt::Int(2) => DebuginfoLevel::Full, + StringOrInt::String(s) if s == "none" => DebuginfoLevel::None, + StringOrInt::Int(0) => DebuginfoLevel::None, + StringOrInt::String(s) if s == "line-tables-only" => DebuginfoLevel::LineTablesOnly, + StringOrInt::String(s) if s == "limited" => DebuginfoLevel::Limited, + StringOrInt::Int(1) => DebuginfoLevel::Limited, + StringOrInt::String(s) if s == "full" => DebuginfoLevel::Full, + StringOrInt::Int(2) => DebuginfoLevel::Full, StringOrInt::Int(n) => { let other = serde::de::Unexpected::Signed(n); return Err(D::Error::invalid_value(other, &"expected 0, 1, or 2")); } StringOrInt::String(s) => { - let other = serde::de::Unexpected::Str(s); + let other = serde::de::Unexpected::Str(&s); return Err(D::Error::invalid_value( other, &"expected none, line-tables-only, limited, or full", @@ -1021,8 +1024,8 @@ impl RustOptimize { #[derive(Deserialize)] #[serde(untagged)] -enum StringOrInt<'a> { - String(&'a str), +enum StringOrInt { + String(String), Int(i64), } From 1d929cf8b719dd454b7966449ed8666bfa485de3 Mon Sep 17 00:00:00 2001 From: klensy Date: Wed, 17 Apr 2024 15:43:52 +0300 Subject: [PATCH 2/2] allow to set line-directives-only too --- config.example.toml | 7 ++----- src/bootstrap/src/core/config/config.rs | 5 +++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config.example.toml b/config.example.toml index 0d4b4e9e7e026..5c1fac7672a9a 100644 --- a/config.example.toml +++ b/config.example.toml @@ -517,11 +517,8 @@ #overflow-checks-std = rust.overflow-checks (boolean) # Debuginfo level for most of Rust code, corresponds to the `-C debuginfo=N` option of `rustc`. -# `0` - no debug info -# `1` - line tables only - sufficient to generate backtraces that include line -# information and inlined functions, set breakpoints at source code -# locations, and step through execution in a debugger. -# `2` - full debug info with variable and type information +# See https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo for available options. +# # Can be overridden for specific subsets of Rust code (rustc, std or tools). # Debuginfo for tests run with compiletest is not controlled by this option # and needs to be enabled separately with `debuginfo-level-tests`. diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 38bf4718b5a9b..2bb899a064f37 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -55,6 +55,7 @@ pub enum DryRun { pub enum DebuginfoLevel { #[default] None, + LineDirectivesOnly, LineTablesOnly, Limited, Full, @@ -72,6 +73,9 @@ impl<'de> Deserialize<'de> for DebuginfoLevel { Ok(match Deserialize::deserialize(deserializer)? { StringOrInt::String(s) if s == "none" => DebuginfoLevel::None, StringOrInt::Int(0) => DebuginfoLevel::None, + StringOrInt::String(s) if s == "line-directives-only" => { + DebuginfoLevel::LineDirectivesOnly + } StringOrInt::String(s) if s == "line-tables-only" => DebuginfoLevel::LineTablesOnly, StringOrInt::String(s) if s == "limited" => DebuginfoLevel::Limited, StringOrInt::Int(1) => DebuginfoLevel::Limited, @@ -98,6 +102,7 @@ impl Display for DebuginfoLevel { use DebuginfoLevel::*; f.write_str(match self { None => "0", + LineDirectivesOnly => "line-directives-only", LineTablesOnly => "line-tables-only", Limited => "1", Full => "2",