Skip to content

Commit 93a807f

Browse files
committed
[bootstrap] Move the split-debuginfo setting to the per-target section
1 parent b054da8 commit 93a807f

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
@@ -543,23 +543,15 @@
543543
# FIXME(#61117): Some tests fail when this option is enabled.
544544
#debuginfo-level-tests = 0
545545

546-
# Should rustc be build with split debuginfo? Default is platform dependent.
547-
# Valid values are the same as those accepted by `-C split-debuginfo`
548-
# (`off`/`unpacked`/`packed`).
546+
# Should rustc and the standard library be built with split debuginfo? Default
547+
# is platform dependent.
549548
#
550-
# On Linux, split debuginfo is disabled by default.
549+
# This field is deprecated, use `target.<triple>.split-debuginfo` instead.
551550
#
552-
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
553-
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
554-
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
555-
# no clear benefit, and also makes it more difficult for debuggers to find
556-
# debug info. The compiler currently defaults to running `dsymutil` to preserve
557-
# its historical default, but when compiling the compiler itself, we skip it by
558-
# default since we know it's safe to do so in that case.
551+
# The value specified here is only used when targeting the `build.build` triple,
552+
# and is overridden by `target.<triple>.split-debuginfo` if specified.
559553
#
560-
# On Windows platforms, packed debuginfo is the only supported option,
561-
# producing a `.pdb` file.
562-
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
554+
#split-debuginfo = see target.<triple>.split-debuginfo
563555

564556
# Whether or not `panic!`s generate backtraces (RUST_BACKTRACE)
565557
#backtrace = true
@@ -769,6 +761,26 @@
769761
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
770762
#linker = "cc" (path)
771763

764+
# Should rustc and the standard library be built with split debuginfo? Default
765+
# is platform dependent.
766+
#
767+
# Valid values are the same as those accepted by `-C split-debuginfo`
768+
# (`off`/`unpacked`/`packed`).
769+
#
770+
# On Linux, split debuginfo is disabled by default.
771+
#
772+
# On Apple platforms, unpacked split debuginfo is used by default. Unpacked
773+
# debuginfo does not run `dsymutil`, which packages debuginfo from disparate
774+
# object files into a single `.dSYM` file. `dsymutil` adds time to builds for
775+
# no clear benefit, and also makes it more difficult for debuggers to find
776+
# debug info. The compiler currently defaults to running `dsymutil` to preserve
777+
# its historical default, but when compiling the compiler itself, we skip it by
778+
# default since we know it's safe to do so in that case.
779+
#
780+
# On Windows platforms, packed debuginfo is the only supported option,
781+
# producing a `.pdb` file.
782+
#split-debuginfo = if linux { off } else if windows { packed } else if apple { unpacked }
783+
772784
# Path to the `llvm-config` binary of the installation of a custom LLVM to link
773785
# against. Note that if this is specified we don't compile LLVM at all for this
774786
# 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
@@ -255,7 +255,7 @@ pub struct Config {
255255
pub rust_debuginfo_level_std: DebuginfoLevel,
256256
pub rust_debuginfo_level_tools: DebuginfoLevel,
257257
pub rust_debuginfo_level_tests: DebuginfoLevel,
258-
pub rust_split_debuginfo: SplitDebuginfo,
258+
pub rust_split_debuginfo_for_build_triple: Option<SplitDebuginfo>, // FIXME: Deprecated field. Remove in Q3'24.
259259
pub rust_rpath: bool,
260260
pub rust_strip: bool,
261261
pub rust_frame_pointers: bool,
@@ -571,6 +571,7 @@ pub struct Target {
571571
pub ranlib: Option<PathBuf>,
572572
pub default_linker: Option<PathBuf>,
573573
pub linker: Option<PathBuf>,
574+
pub split_debuginfo: Option<SplitDebuginfo>,
574575
pub sanitizers: Option<bool>,
575576
pub profiler: Option<StringOrBool>,
576577
pub rpath: Option<bool>,
@@ -1128,6 +1129,7 @@ define_config! {
11281129
ranlib: Option<String> = "ranlib",
11291130
default_linker: Option<PathBuf> = "default-linker",
11301131
linker: Option<String> = "linker",
1132+
split_debuginfo: Option<String> = "split-debuginfo",
11311133
llvm_config: Option<String> = "llvm-config",
11321134
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
11331135
llvm_filecheck: Option<String> = "llvm-filecheck",
@@ -1620,11 +1622,18 @@ impl Config {
16201622
debuginfo_level_tools = debuginfo_level_tools_toml;
16211623
debuginfo_level_tests = debuginfo_level_tests_toml;
16221624

1623-
config.rust_split_debuginfo = split_debuginfo
1625+
config.rust_split_debuginfo_for_build_triple = split_debuginfo
16241626
.as_deref()
16251627
.map(SplitDebuginfo::from_str)
1626-
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
1627-
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
1628+
.map(|v| v.expect("invalid value for rust.split-debuginfo"));
1629+
1630+
if config.rust_split_debuginfo_for_build_triple.is_some() {
1631+
println!(
1632+
"WARNING: specifying `rust.split-debuginfo` is deprecated, use `target.{}.split-debuginfo` instead",
1633+
config.build
1634+
);
1635+
}
1636+
16281637
optimize = optimize_toml;
16291638
omit_git_hash = omit_git_hash_toml;
16301639
config.rust_new_symbol_mangling = new_symbol_mangling;
@@ -1845,10 +1854,11 @@ impl Config {
18451854
if let Some(ref s) = cfg.llvm_filecheck {
18461855
target.llvm_filecheck = Some(config.src.join(s));
18471856
}
1848-
target.llvm_libunwind = cfg
1849-
.llvm_libunwind
1850-
.as_ref()
1851-
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
1857+
target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| {
1858+
v.parse().unwrap_or_else(|_| {
1859+
panic!("failed to parse target.{triple}.llvm-libunwind")
1860+
})
1861+
});
18521862
if let Some(s) = cfg.no_std {
18531863
target.no_std = s;
18541864
}
@@ -1884,6 +1894,12 @@ impl Config {
18841894
}).collect());
18851895
}
18861896

1897+
target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| {
1898+
v.parse().unwrap_or_else(|_| {
1899+
panic!("invalid value for target.{triple}.split-debuginfo")
1900+
})
1901+
});
1902+
18871903
config.target_config.insert(TargetSelection::from_user(&triple), target);
18881904
}
18891905
}
@@ -2282,6 +2298,16 @@ impl Config {
22822298
})
22832299
}
22842300

2301+
pub fn split_debuginfo(&self, target: TargetSelection) -> SplitDebuginfo {
2302+
self.target_config
2303+
.get(&target)
2304+
.and_then(|t| t.split_debuginfo)
2305+
.or_else(|| {
2306+
if self.build == target { self.rust_split_debuginfo_for_build_triple } else { None }
2307+
})
2308+
.unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
2309+
}
2310+
22852311
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
22862312
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
22872313
}

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
141141
severity: ChangeSeverity::Info,
142142
summary: "A new `boostrap-cache-path` option has been introduced which can be utilized to modify the cache path for bootstrap.",
143143
},
144+
ChangeInfo {
145+
change_id: 121754,
146+
severity: ChangeSeverity::Warning,
147+
summary: "`rust.split-debuginfo` has been moved to `target.<triple>.split-debuginfo` and its default value is determined for each target individually.",
148+
},
144149
];

0 commit comments

Comments
 (0)