Skip to content

Commit 0e354c9

Browse files
committed
[bootstrap] Move the split-debuginfo setting to the per-target section
1 parent 6554a56 commit 0e354c9

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
@@ -773,6 +765,26 @@
773765
# Setting this will override the `use-lld` option for Rust code when targeting MSVC.
774766
#linker = "cc" (path)
775767

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

src/bootstrap/src/core/builder.rs

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

1734+
let split_debuginfo = self.config.split_debuginfo(target);
17341735
let split_debuginfo_is_stable = target.contains("linux")
17351736
|| target.contains("apple")
1736-
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
1737-
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
1737+
|| (target.is_msvc() && split_debuginfo == SplitDebuginfo::Packed)
1738+
|| (target.is_windows() && split_debuginfo == SplitDebuginfo::Off);
17381739

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

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

+34-8
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ pub struct Config {
256256
pub rust_debuginfo_level_std: DebuginfoLevel,
257257
pub rust_debuginfo_level_tools: DebuginfoLevel,
258258
pub rust_debuginfo_level_tests: DebuginfoLevel,
259-
pub rust_split_debuginfo: SplitDebuginfo,
259+
pub rust_split_debuginfo_for_build_triple: Option<SplitDebuginfo>, // FIXME: Deprecated field. Remove in Q3'24.
260260
pub rust_rpath: bool,
261261
pub rust_strip: bool,
262262
pub rust_frame_pointers: bool,
@@ -574,6 +574,7 @@ pub struct Target {
574574
pub ranlib: Option<PathBuf>,
575575
pub default_linker: Option<PathBuf>,
576576
pub linker: Option<PathBuf>,
577+
pub split_debuginfo: Option<SplitDebuginfo>,
577578
pub sanitizers: Option<bool>,
578579
pub profiler: Option<StringOrBool>,
579580
pub rpath: Option<bool>,
@@ -1133,6 +1134,7 @@ define_config! {
11331134
ranlib: Option<String> = "ranlib",
11341135
default_linker: Option<PathBuf> = "default-linker",
11351136
linker: Option<String> = "linker",
1137+
split_debuginfo: Option<String> = "split-debuginfo",
11361138
llvm_config: Option<String> = "llvm-config",
11371139
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
11381140
llvm_filecheck: Option<String> = "llvm-filecheck",
@@ -1627,11 +1629,18 @@ impl Config {
16271629
debuginfo_level_tools = debuginfo_level_tools_toml;
16281630
debuginfo_level_tests = debuginfo_level_tests_toml;
16291631

1630-
config.rust_split_debuginfo = split_debuginfo
1632+
config.rust_split_debuginfo_for_build_triple = split_debuginfo
16311633
.as_deref()
16321634
.map(SplitDebuginfo::from_str)
1633-
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
1634-
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
1635+
.map(|v| v.expect("invalid value for rust.split-debuginfo"));
1636+
1637+
if config.rust_split_debuginfo_for_build_triple.is_some() {
1638+
println!(
1639+
"WARNING: specifying `rust.split-debuginfo` is deprecated, use `target.{}.split-debuginfo` instead",
1640+
config.build
1641+
);
1642+
}
1643+
16351644
optimize = optimize_toml;
16361645
omit_git_hash = omit_git_hash_toml;
16371646
config.rust_new_symbol_mangling = new_symbol_mangling;
@@ -1853,10 +1862,11 @@ impl Config {
18531862
if let Some(ref s) = cfg.llvm_filecheck {
18541863
target.llvm_filecheck = Some(config.src.join(s));
18551864
}
1856-
target.llvm_libunwind = cfg
1857-
.llvm_libunwind
1858-
.as_ref()
1859-
.map(|v| v.parse().expect("failed to parse rust.llvm-libunwind"));
1865+
target.llvm_libunwind = cfg.llvm_libunwind.as_ref().map(|v| {
1866+
v.parse().unwrap_or_else(|_| {
1867+
panic!("failed to parse target.{triple}.llvm-libunwind")
1868+
})
1869+
});
18601870
if let Some(s) = cfg.no_std {
18611871
target.no_std = s;
18621872
}
@@ -1893,6 +1903,12 @@ impl Config {
18931903
}).collect());
18941904
}
18951905

1906+
target.split_debuginfo = cfg.split_debuginfo.as_ref().map(|v| {
1907+
v.parse().unwrap_or_else(|_| {
1908+
panic!("invalid value for target.{triple}.split-debuginfo")
1909+
})
1910+
});
1911+
18961912
config.target_config.insert(TargetSelection::from_user(&triple), target);
18971913
}
18981914
}
@@ -2291,6 +2307,16 @@ impl Config {
22912307
})
22922308
}
22932309

2310+
pub fn split_debuginfo(&self, target: TargetSelection) -> SplitDebuginfo {
2311+
self.target_config
2312+
.get(&target)
2313+
.and_then(|t| t.split_debuginfo)
2314+
.or_else(|| {
2315+
if self.build == target { self.rust_split_debuginfo_for_build_triple } else { None }
2316+
})
2317+
.unwrap_or_else(|| SplitDebuginfo::default_for_platform(target))
2318+
}
2319+
22942320
pub fn submodules(&self, rust_info: &GitInfo) -> bool {
22952321
self.submodules.unwrap_or(rust_info.is_managed_git_subrepository())
22962322
}

src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
151151
severity: ChangeSeverity::Info,
152152
summary: "New option `rust.llvm-bitcode-linker` that will build the llvm-bitcode-linker.",
153153
},
154+
ChangeInfo {
155+
change_id: 121754,
156+
severity: ChangeSeverity::Warning,
157+
summary: "`rust.split-debuginfo` has been moved to `target.<triple>.split-debuginfo` and its default value is determined for each target individually.",
158+
},
154159
];

0 commit comments

Comments
 (0)