Skip to content

Commit 9a3eb33

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

File tree

4 files changed

+69
-25
lines changed

4 files changed

+69
-25
lines changed

config.example.toml

+26-14
Original file line numberDiff line numberDiff line change
@@ -539,23 +539,15 @@
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`).
542+
# Should rustc and the standard library be built with split debuginfo? Default
543+
# is platform dependent.
545544
#
546-
# On Linux, split debuginfo is disabled by default.
545+
# This field is deprecated, use `target.<triple>.split-debuginfo` instead.
547546
#
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.
547+
# The value specified here is only used when targeting the `build.build` triple,
548+
# and is overridden by `target.<triple>.split-debuginfo` if specified.
555549
#
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 }
550+
#split-debuginfo = see target.<triple>.split-debuginfo
559551

560552
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
561553
#backtrace = true
@@ -765,6 +757,26 @@
765757
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
766758
#linker = "cc" (path)
767759

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

+34-8
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ 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,
257+
pub rust_split_debuginfo_for_build_triple: Option<SplitDebuginfo>, // FIXME: Deprecated field. Remove in Q3'24.
258258
pub rust_rpath: bool,
259259
pub rust_strip: bool,
260260
pub rust_frame_pointers: bool,
@@ -570,6 +570,7 @@ pub struct Target {
570570
pub ranlib: Option<PathBuf>,
571571
pub default_linker: Option<PathBuf>,
572572
pub linker: Option<PathBuf>,
573+
pub split_debuginfo: Option<SplitDebuginfo>,
573574
pub sanitizers: Option<bool>,
574575
pub profiler: Option<StringOrBool>,
575576
pub rpath: Option<bool>,
@@ -1126,6 +1127,7 @@ define_config! {
11261127
ranlib: Option<String> = "ranlib",
11271128
default_linker: Option<PathBuf> = "default-linker",
11281129
linker: Option<String> = "linker",
1130+
split_debuginfo: Option<String> = "split-debuginfo",
11291131
llvm_config: Option<String> = "llvm-config",
11301132
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
11311133
llvm_filecheck: Option<String> = "llvm-filecheck",
@@ -1616,11 +1618,18 @@ impl Config {
16161618
debuginfo_level_tools = debuginfo_level_tools_toml;
16171619
debuginfo_level_tests = debuginfo_level_tests_toml;
16181620

1619-
config.rust_split_debuginfo = split_debuginfo
1621+
config.rust_split_debuginfo_for_build_triple = split_debuginfo
16201622
.as_deref()
16211623
.map(SplitDebuginfo::from_str)
1622-
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
1623-
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
1624+
.map(|v| v.expect("invalid value for rust.split-debuginfo"));
1625+
1626+
if config.rust_split_debuginfo_for_build_triple.is_some() {
1627+
println!(
1628+
"WARNING: specifying `rust.split-debuginfo` is deprecated, use `target.{}.split-debuginfo` instead",
1629+
config.build
1630+
);
1631+
}
1632+
16241633
optimize = optimize_toml;
16251634
omit_git_hash = omit_git_hash_toml;
16261635
config.rust_new_symbol_mangling = new_symbol_mangling;
@@ -1841,10 +1850,11 @@ impl Config {
18411850
if let Some(ref s) = cfg.llvm_filecheck {
18421851
target.llvm_filecheck = Some(config.src.join(s));
18431852
}
1844-
target.llvm_libunwind = cfg
1845-
.llvm_libunwind
1846-
.as_ref()
1847-
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
1853+
target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| {
1854+
v.parse().unwrap_or_else(|_| {
1855+
panic!("failed to parse target.{triple}.llvm-libunwind")
1856+
})
1857+
});
18481858
if let Some(s) = cfg.no_std {
18491859
target.no_std = s;
18501860
}
@@ -1880,6 +1890,12 @@ impl Config {
18801890
}).collect());
18811891
}
18821892

1893+
target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| {
1894+
v.parse().unwrap_or_else(|_| {
1895+
panic!("invalid value for target.{triple}.split_debuginfo")
1896+
})
1897+
});
1898+
18831899
config.target_config.insert(TargetSelection::from_user(&triple), target);
18841900
}
18851901
}
@@ -2278,6 +2294,16 @@ impl Config {
22782294
})
22792295
}
22802296

2297+
pub fn split_debuginfo(&self, target: TargetSelection) -> SplitDebuginfo {
2298+
self.target_config
2299+
.get(&target)
2300+
.and_then(|t| t.split_debuginfo)
2301+
.or_else(|| {
2302+
if self.build == target { self.rust_split_debuginfo_for_build_triple } else { None }
2303+
})
2304+
.unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
2305+
}
2306+
22812307
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
22822308
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
22832309
}

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: 121754,
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)