Skip to content

Commit de8a80b

Browse files
committed
[bootstrap] Move the split-debuginfo setting to the per-target section
1 parent ef32456 commit de8a80b

File tree

5 files changed

+63
-31
lines changed

5 files changed

+63
-31
lines changed

config.example.toml

+20-18
Original file line numberDiff line numberDiff line change
@@ -539,24 +539,6 @@
539539
# FIXME(#61117): Some tests fail when this option is enabled.
540540
#debuginfo-level-tests = 0
541541

542-
# Should rustc be build with split debuginfo? Default is platform dependent.
543-
# Valid values are the same as those accepted by `-C split-debuginfo`
544-
# (`off`/`unpacked`/`packed`).
545-
#
546-
# On Linux, split debuginfo is disabled by default.
547-
#
548-
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
549-
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
550-
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
551-
# no clear benefit, and also makes it more difficult for debuggers to find
552-
# debug info. The compiler currently defaults to running `dsymutil` to preserve
553-
# its historical default, but when compiling the compiler itself, we skip it by
554-
# default since we know it's safe to do so in that case.
555-
#
556-
# On Windows platforms, packed debuginfo is the only supported option,
557-
# producing a `.pdb` file.
558-
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
559-
560542
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
561543
#backtrace = true
562544

@@ -765,6 +747,26 @@
765747
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
766748
#linker = "cc" (path)
767749

750+
# Should rustc and the standard library be built with split debuginfo? Default
751+
# is platform dependent.
752+
#
753+
# Valid values are the same as those accepted by `-C split-debuginfo`
754+
# (`off`/`unpacked`/`packed`).
755+
#
756+
# On Linux, split debuginfo is disabled by default.
757+
#
758+
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
759+
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
760+
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
761+
# no clear benefit, and also makes it more difficult for debuggers to find
762+
# debug info. The compiler currently defaults to running `dsymutil` to preserve
763+
# its historical default, but when compiling the compiler itself, we skip it by
764+
# default since we know it's safe to do so in that case.
765+
#
766+
# On Windows platforms, packed debuginfo is the only supported option,
767+
# producing a `.pdb` file.
768+
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
769+
768770
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
769771
# against. Note that if this is specified we don't compile LLVM at all for this
770772
# target.

src/bootstrap/src/core/builder.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1730,15 +1730,16 @@ impl<'a> Builder<'a> {
17301730
},
17311731
);
17321732

1733+
let split_debuginfo = self.config.split_debuginfo(target);
17331734
let split_debuginfo_is_stable = target.contains("linux")
17341735
|| target.contains("apple")
1735-
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
1736-
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
1736+
|| (target.is_msvc() && split_debuginfo == SplitDebuginfo::Packed)
1737+
|| (target.is_windows() && split_debuginfo == SplitDebuginfo::Off);
17371738

17381739
if !split_debuginfo_is_stable {
17391740
rustflags.arg("-Zunstable-options");
17401741
}
1741-
match self.config.rust_split_debuginfo {
1742+
match split_debuginfo {
17421743
SplitDebuginfo::Packed => rustflags.arg("-Csplit-debuginfo=packed"),
17431744
SplitDebuginfo::Unpacked => rustflags.arg("-Csplit-debuginfo=unpacked"),
17441745
SplitDebuginfo::Off => rustflags.arg("-Csplit-debuginfo=off"),

src/bootstrap/src/core/config/config.rs

+28-10
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,6 @@ pub struct Config {
254254
pub rust_debuginfo_level_std: DebuginfoLevel,
255255
pub rust_debuginfo_level_tools: DebuginfoLevel,
256256
pub rust_debuginfo_level_tests: DebuginfoLevel,
257-
pub rust_split_debuginfo: SplitDebuginfo,
258257
pub rust_rpath: bool,
259258
pub rust_strip: bool,
260259
pub rust_frame_pointers: bool,
@@ -570,6 +569,7 @@ pub struct Target {
570569
pub ranlib: Option<PathBuf>,
571570
pub default_linker: Option<PathBuf>,
572571
pub linker: Option<PathBuf>,
572+
pub split_debuginfo: Option<SplitDebuginfo>,
573573
pub sanitizers: Option<bool>,
574574
pub profiler: Option<StringOrBool>,
575575
pub rpath: Option<bool>,
@@ -1126,6 +1126,7 @@ define_config! {
11261126
ranlib: Option<String> = "ranlib",
11271127
default_linker: Option<PathBuf> = "default-linker",
11281128
linker: Option<String> = "linker",
1129+
split_debuginfo: Option<String> = "split-debuginfo",
11291130
llvm_config: Option<String> = "llvm-config",
11301131
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
11311132
llvm_filecheck: Option<String> = "llvm-filecheck",
@@ -1616,11 +1617,14 @@ impl Config {
16161617
debuginfo_level_tools = debuginfo_level_tools_toml;
16171618
debuginfo_level_tests = debuginfo_level_tests_toml;
16181619

1619-
config.rust_split_debuginfo = split_debuginfo
1620-
.as_deref()
1621-
.map(SplitDebuginfo::from_str)
1622-
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
1623-
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
1620+
// FIXME: Remove this and the `Rust.split_debuginfo` field after people had time to
1621+
// migrate. (The changelog can only be shown if the config parses successfully, so keep
1622+
// the field around and provide a useful error message).
1623+
assert!(
1624+
split_debuginfo.is_none(),
1625+
"`rust.split_debuginfo` is no longer supported, specify `target.<triple>.split_debuginfo` instead."
1626+
);
1627+
16241628
optimize = optimize_toml;
16251629
omit_git_hash = omit_git_hash_toml;
16261630
config.rust_new_symbol_mangling = new_symbol_mangling;
@@ -1841,10 +1845,11 @@ impl Config {
18411845
if let Some(ref s) = cfg.llvm_filecheck {
18421846
target.llvm_filecheck = Some(config.src.join(s));
18431847
}
1844-
target.llvm_libunwind = cfg
1845-
.llvm_libunwind
1846-
.as_ref()
1847-
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
1848+
target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| {
1849+
v.parse().unwrap_or_else(|_| {
1850+
panic!("failed to parse target.{triple}.llvm-libunwind")
1851+
})
1852+
});
18481853
if let Some(s) = cfg.no_std {
18491854
target.no_std = s;
18501855
}
@@ -1880,6 +1885,12 @@ impl Config {
18801885
}).collect());
18811886
}
18821887

1888+
target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| {
1889+
v.parse().unwrap_or_else(|_| {
1890+
panic!("invalid value for target.{triple}.split_debuginfo")
1891+
})
1892+
});
1893+
18831894
config.target_config.insert(TargetSelection::from_user(&triple), target);
18841895
}
18851896
}
@@ -2278,6 +2289,13 @@ impl Config {
22782289
})
22792290
}
22802291

2292+
pub fn split_debuginfo(&self, target: TargetSelection) -> SplitDebuginfo {
2293+
self.target_config
2294+
.get(&target)
2295+
.and_then(|t| t.split_debuginfo)
2296+
.unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
2297+
}
2298+
22812299
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
22822300
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
22832301
}

src/bootstrap/src/core/config/tests.rs

+6
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,9 @@ fn rust_lld() {
237237
assert!(matches!(parse("rust.use-lld = true").lld_mode, LldMode::External));
238238
assert!(matches!(parse("rust.use-lld = false").lld_mode, LldMode::Unused));
239239
}
240+
241+
#[test]
242+
#[should_panic(expected = "`rust.split_debuginfo` is no longer supported")]
243+
fn split_debuginfo_wrong_location() {
244+
parse("rust.split-debuginfo = \"off\"");
245+
}

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
136136
severity: ChangeSeverity::Info,
137137
summary: "`x install` now skips providing tarball sources (under 'build/dist' path) to speed up the installation process.",
138138
},
139+
ChangeInfo {
140+
change_id: 0, // TODO
141+
severity: ChangeSeverity::Warning,
142+
summary: "`rust.split-debuginfo` has been moved to `target.<triple>.split-debuginfo` and its default value is determined for each target individually.",
143+
},
139144
];

0 commit comments

Comments
 (0)