Skip to content

Commit 53418f6

Browse files
authored
Rollup merge of rust-lang#98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
session: stabilize split debuginfo on linux Stabilize the `-Csplit-debuginfo` flag... - ...on Linux for all values of the flag. Split DWARF has been implemented for a few months, hasn't had any bug reports and has had some promising benchmarking for incremental debug build performance. - ..on other platforms for the default value. It doesn't make any sense that `-Csplit-debuginfo=packed` is unstable on Windows MSVC when that's the default behaviour, but keep the other values unstable.
2 parents b998821 + de917d8 commit 53418f6

File tree

13 files changed

+89
-46
lines changed

13 files changed

+89
-46
lines changed

compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2423,13 +2423,6 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
24232423

24242424
let pretty = parse_pretty(&unstable_opts, error_format);
24252425

2426-
if !unstable_opts.unstable_options
2427-
&& !target_triple.triple().contains("apple")
2428-
&& cg.split_debuginfo.is_some()
2429-
{
2430-
early_error(error_format, "`-Csplit-debuginfo` is unstable on this platform");
2431-
}
2432-
24332426
// Try to find a directory containing the Rust `src`, for more details see
24342427
// the doc comment on the `real_rust_source_base_dir` field.
24352428
let tmp_buf;

compiler/rustc_session/src/session.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,9 @@ impl Session {
661661
)
662662
}
663663

664+
/// Returns `true` if the target can use the current split debuginfo configuration.
664665
pub fn target_can_use_split_dwarf(&self) -> bool {
665-
!self.target.is_like_windows && !self.target.is_like_osx
666+
self.target.options.supported_split_debuginfo.contains(&self.split_debuginfo())
666667
}
667668

668669
pub fn generate_proc_macro_decls_symbol(&self, stable_crate_id: StableCrateId) -> String {
@@ -1543,6 +1544,13 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
15431544
sess.err(&format!("requested DWARF version {} is greater than 5", dwarf_version));
15441545
}
15451546
}
1547+
1548+
if !sess.target_can_use_split_dwarf() && !sess.opts.unstable_opts.unstable_options {
1549+
sess.err(&format!(
1550+
"`-Csplit-debuginfo={}` is unstable on this platform",
1551+
sess.split_debuginfo()
1552+
));
1553+
}
15461554
}
15471555

15481556
/// Holds data on the current incremental compilation session, if there is one.

compiler/rustc_target/src/spec/apple_base.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ pub fn opts(os: &'static str, arch: &'static str, abi: &'static str) -> TargetOp
7979
// The historical default for macOS targets is to run `dsymutil` which
8080
// generates a packed version of debuginfo split from the main file.
8181
split_debuginfo: SplitDebuginfo::Packed,
82+
supported_split_debuginfo: Cow::Borrowed(&[
83+
SplitDebuginfo::Packed,
84+
SplitDebuginfo::Unpacked,
85+
SplitDebuginfo::Off,
86+
]),
8287

8388
// This environment variable is pretty magical but is intended for
8489
// producing deterministic builds. This was first discovered to be used

compiler/rustc_target/src/spec/linux_base.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use crate::spec::{cvs, RelroLevel, TargetOptions};
1+
use crate::spec::{cvs, RelroLevel, SplitDebuginfo, TargetOptions};
2+
use std::borrow::Cow;
23

34
pub fn opts() -> TargetOptions {
45
TargetOptions {
@@ -10,6 +11,11 @@ pub fn opts() -> TargetOptions {
1011
relro_level: RelroLevel::Full,
1112
has_thread_local: true,
1213
crt_static_respected: true,
14+
supported_split_debuginfo: Cow::Borrowed(&[
15+
SplitDebuginfo::Packed,
16+
SplitDebuginfo::Unpacked,
17+
SplitDebuginfo::Off,
18+
]),
1319
..Default::default()
1420
}
1521
}

compiler/rustc_target/src/spec/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,8 @@ pub struct TargetOptions {
14411441
/// How to handle split debug information, if at all. Specifying `None` has
14421442
/// target-specific meaning.
14431443
pub split_debuginfo: SplitDebuginfo,
1444+
/// Which kinds of split debuginfo are supported by the target?
1445+
pub supported_split_debuginfo: StaticCow<[SplitDebuginfo]>,
14441446

14451447
/// The sanitizers supported by this target
14461448
///
@@ -1599,6 +1601,8 @@ impl Default for TargetOptions {
15991601
eh_frame_header: true,
16001602
has_thumb_interworking: false,
16011603
split_debuginfo: SplitDebuginfo::Off,
1604+
// `Off` is supported by default, but targets can remove this manually, e.g. Windows.
1605+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
16021606
supported_sanitizers: SanitizerSet::empty(),
16031607
default_adjusted_cabi: None,
16041608
c_enum_min_bits: 32,
@@ -1907,6 +1911,25 @@ impl Target {
19071911
}
19081912
}
19091913
} );
1914+
($key_name:ident, falliable_list) => ( {
1915+
let name = (stringify!($key_name)).replace("_", "-");
1916+
obj.remove(&name).and_then(|j| {
1917+
if let Some(v) = j.as_array() {
1918+
match v.iter().map(|a| FromStr::from_str(a.as_str().unwrap())).collect() {
1919+
Ok(l) => { base.$key_name = l },
1920+
// FIXME: `falliable_list` can't re-use the `key!` macro for list
1921+
// elements and the error messages from that macro, so it has a bad
1922+
// generic message instead
1923+
Err(_) => return Some(Err(
1924+
format!("`{:?}` is not a valid value for `{}`", j, name)
1925+
)),
1926+
}
1927+
} else {
1928+
incorrect_type.push(name)
1929+
}
1930+
Some(Ok(()))
1931+
}).unwrap_or(Ok(()))
1932+
} );
19101933
($key_name:ident, optional) => ( {
19111934
let name = (stringify!($key_name)).replace("_", "-");
19121935
if let Some(o) = obj.remove(&name) {
@@ -2194,6 +2217,7 @@ impl Target {
21942217
key!(eh_frame_header, bool);
21952218
key!(has_thumb_interworking, bool);
21962219
key!(split_debuginfo, SplitDebuginfo)?;
2220+
key!(supported_split_debuginfo, falliable_list)?;
21972221
key!(supported_sanitizers, SanitizerSet)?;
21982222
key!(default_adjusted_cabi, Option<Abi>)?;
21992223
key!(c_enum_min_bits, u64);
@@ -2438,6 +2462,7 @@ impl ToJson for Target {
24382462
target_option_val!(eh_frame_header);
24392463
target_option_val!(has_thumb_interworking);
24402464
target_option_val!(split_debuginfo);
2465+
target_option_val!(supported_split_debuginfo);
24412466
target_option_val!(supported_sanitizers);
24422467
target_option_val!(c_enum_min_bits);
24432468
target_option_val!(generate_arange_section);

compiler/rustc_target/src/spec/msvc_base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::spec::{LinkerFlavor, LldFlavor, SplitDebuginfo, TargetOptions};
2+
use std::borrow::Cow;
23

34
pub fn opts() -> TargetOptions {
45
// Suppress the verbose logo and authorship debugging output, which would needlessly
@@ -18,6 +19,7 @@ pub fn opts() -> TargetOptions {
1819
// Currently this is the only supported method of debuginfo on MSVC
1920
// where `*.pdb` files show up next to the final artifact.
2021
split_debuginfo: SplitDebuginfo::Packed,
22+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Packed]),
2123

2224
..Default::default()
2325
}

compiler/rustc_target/src/spec/windows_gnu_base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::spec::crt_objects::{self, CrtObjectsFallback};
2-
use crate::spec::{cvs, LinkerFlavor, TargetOptions};
2+
use crate::spec::{cvs, LinkerFlavor, SplitDebuginfo, TargetOptions};
3+
use std::borrow::Cow;
34

45
pub fn opts() -> TargetOptions {
56
let mut pre_link_args = TargetOptions::link_args(
@@ -86,6 +87,8 @@ pub fn opts() -> TargetOptions {
8687
emit_debug_gdb_scripts: false,
8788
requires_uwtable: true,
8889
eh_frame_header: false,
90+
// FIXME(davidtwco): Support Split DWARF on Windows GNU.
91+
supported_split_debuginfo: Cow::Borrowed(&[SplitDebuginfo::Off]),
8992
..Default::default()
9093
}
9194
}

src/bootstrap/builder.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,23 +1759,21 @@ impl<'a> Builder<'a> {
17591759
},
17601760
);
17611761

1762-
if !target.contains("windows") {
1763-
let needs_unstable_opts = target.contains("linux")
1764-
|| target.contains("solaris")
1765-
|| target.contains("windows")
1766-
|| target.contains("bsd")
1767-
|| target.contains("dragonfly")
1768-
|| target.contains("illumos");
1769-
1770-
if needs_unstable_opts {
1771-
rustflags.arg("-Zunstable-options");
1772-
}
1773-
match self.config.rust_split_debuginfo {
1774-
SplitDebuginfo::Packed => rustflags.arg("-Csplit-debuginfo=packed"),
1775-
SplitDebuginfo::Unpacked => rustflags.arg("-Csplit-debuginfo=unpacked"),
1776-
SplitDebuginfo::Off => rustflags.arg("-Csplit-debuginfo=off"),
1777-
};
1762+
let split_debuginfo_is_stable = target.contains("linux")
1763+
|| target.contains("apple")
1764+
|| (target.contains("msvc")
1765+
&& self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
1766+
|| (target.contains("windows")
1767+
&& self.config.rust_split_debuginfo == SplitDebuginfo::Off);
1768+
1769+
if !split_debuginfo_is_stable {
1770+
rustflags.arg("-Zunstable-options");
17781771
}
1772+
match self.config.rust_split_debuginfo {
1773+
SplitDebuginfo::Packed => rustflags.arg("-Csplit-debuginfo=packed"),
1774+
SplitDebuginfo::Unpacked => rustflags.arg("-Csplit-debuginfo=unpacked"),
1775+
SplitDebuginfo::Off => rustflags.arg("-Csplit-debuginfo=off"),
1776+
};
17791777

17801778
if self.config.cmd.bless() {
17811779
// Bless `expect!` tests.

src/test/incremental/split_debuginfo_cached.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
// only-x86_64-unknown-linux-gnu
77
// revisions:rpass1 rpass2
88

9-
// [rpass1]compile-flags: -g -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split
10-
// [rpass2]compile-flags: -g -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split
9+
// [rpass1]compile-flags: -g -Zquery-dep-graph -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split
10+
// [rpass2]compile-flags: -g -Zquery-dep-graph -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split
1111

1212
#![feature(rustc_attrs)]
1313
// For `rpass2`, nothing has changed so everything should re-used.

src/test/incremental/split_debuginfo_mode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
// only-x86_64-unknown-linux-gnu
77
// revisions:rpass1 rpass2 rpass3 rpass4
88

9-
// [rpass1]compile-flags: -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=single -Zsplit-dwarf-inlining=on
10-
// [rpass2]compile-flags: -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=packed -Zsplit-dwarf-kind=single -Zsplit-dwarf-inlining=on
11-
// [rpass3]compile-flags: -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split -Zsplit-dwarf-inlining=on
12-
// [rpass4]compile-flags: -Zquery-dep-graph -Zunstable-options -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split -Zsplit-dwarf-inlining=off
9+
// [rpass1]compile-flags: -Zquery-dep-graph -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=single -Zsplit-dwarf-inlining=on
10+
// [rpass2]compile-flags: -Zquery-dep-graph -Csplit-debuginfo=packed -Zsplit-dwarf-kind=single -Zsplit-dwarf-inlining=on
11+
// [rpass3]compile-flags: -Zquery-dep-graph -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split -Zsplit-dwarf-inlining=on
12+
// [rpass4]compile-flags: -Zquery-dep-graph -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split -Zsplit-dwarf-inlining=off
1313

1414
#![feature(rustc_attrs)]
1515
// For rpass2 we change -Csplit-debuginfo and thus expect every CGU to be recompiled

src/test/run-make-fulldeps/split-debuginfo/Makefile

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ unpacked:
3636
else
3737
# If disabled, don't run dsymutil
3838
off:
39-
$(RUSTC) foo.rs -g -C split-debuginfo=off -Z unstable-options
39+
$(RUSTC) foo.rs -g -C split-debuginfo=off
4040
[ ! -f $(TMPDIR)/*.dwp ]
4141
[ ! -f $(TMPDIR)/*.dwo ]
4242

@@ -47,32 +47,32 @@ off:
4747
packed: packed-split packed-single
4848

4949
packed-split:
50-
$(RUSTC) foo.rs -g -C split-debuginfo=packed -Z unstable-options -Zsplit-dwarf-kind=split
50+
$(RUSTC) foo.rs -g -C split-debuginfo=packed -Zsplit-dwarf-kind=split
5151
ls $(TMPDIR)/*.dwp
5252
rm -rf $(TMPDIR)/*.dwp $(TMPDIR)/*.dwo
5353

5454
packed-single:
55-
$(RUSTC) foo.rs -g -C split-debuginfo=packed -Z unstable-options -Zsplit-dwarf-kind=single
55+
$(RUSTC) foo.rs -g -C split-debuginfo=packed -Zsplit-dwarf-kind=single
5656
ls $(TMPDIR)/*.dwp
5757
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
5858
rm -rf $(TMPDIR)/*.dwp
5959

6060
packed-remapped: packed-remapped-split packed-remapped-single
6161

6262
packed-remapped-split:
63-
$(RUSTC) -Z unstable-options -C split-debuginfo=packed -C debuginfo=2 \
63+
$(RUSTC) -C split-debuginfo=packed -C debuginfo=2 \
6464
-Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
6565
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
6666

6767
packed-remapped-single:
68-
$(RUSTC) -Z unstable-options -C split-debuginfo=packed -C debuginfo=2 \
68+
$(RUSTC) -C split-debuginfo=packed -C debuginfo=2 \
6969
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
7070
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
7171

7272
packed-crosscrate: packed-crosscrate-split packed-crosscrate-single
7373

7474
packed-crosscrate-split:
75-
$(RUSTC) --crate-type lib -Z unstable-options -C split-debuginfo=packed \
75+
$(RUSTC) --crate-type lib -C split-debuginfo=packed \
7676
-Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs
7777
ls $(TMPDIR)/*.rlib
7878
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
@@ -84,7 +84,7 @@ packed-crosscrate-split:
8484
rm $(TMPDIR)/$(call BIN,main)
8585

8686
packed-crosscrate-single:
87-
$(RUSTC) --crate-type lib -Z unstable-options -C split-debuginfo=packed \
87+
$(RUSTC) --crate-type lib -C split-debuginfo=packed \
8888
-Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs
8989
ls $(TMPDIR)/*.rlib
9090
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
@@ -98,23 +98,23 @@ packed-crosscrate-single:
9898
unpacked: unpacked-split unpacked-single unpacked-remapped-split unpacked-remapped-single
9999

100100
unpacked-split:
101-
$(RUSTC) foo.rs -g -C split-debuginfo=unpacked -Z unstable-options -Zsplit-dwarf-kind=split
101+
$(RUSTC) foo.rs -g -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split
102102
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
103103
ls $(TMPDIR)/*.dwo
104104
rm -rf $(TMPDIR)/*.dwp $(TMPDIR)/*.dwo
105105

106106
unpacked-single:
107-
$(RUSTC) foo.rs -g -C split-debuginfo=unpacked -Z unstable-options -Zsplit-dwarf-kind=single
107+
$(RUSTC) foo.rs -g -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single
108108
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
109109
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
110110

111111
unpacked-remapped-split:
112-
$(RUSTC) -Z unstable-options -C split-debuginfo=unpacked -C debuginfo=2 \
112+
$(RUSTC) -C split-debuginfo=unpacked -C debuginfo=2 \
113113
-Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g
114114
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
115115

116116
unpacked-remapped-single:
117-
$(RUSTC) -Z unstable-options -C split-debuginfo=unpacked -C debuginfo=2 \
117+
$(RUSTC) -C split-debuginfo=unpacked -C debuginfo=2 \
118118
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
119119
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
120120
endif

src/test/ui/debuginfo/debuginfo-emit-llvm-ir-and-split-debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// build-pass
22
//
3-
// compile-flags: -g --emit=llvm-ir -Zunstable-options -Csplit-debuginfo=unpacked
3+
// compile-flags: -g --emit=llvm-ir -Csplit-debuginfo=unpacked
44
//
55
// Make sure that we don't explode with an error if we don't actually end up emitting any `dwo`s,
66
// as would be the case if we don't actually codegen anything.

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,11 +2015,14 @@ impl<'test> TestCx<'test> {
20152015
Some(CompareMode::Chalk) => {
20162016
rustc.args(&["-Zchalk"]);
20172017
}
2018-
Some(CompareMode::SplitDwarf) => {
2018+
Some(CompareMode::SplitDwarf) if self.config.target.contains("windows") => {
20192019
rustc.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]);
20202020
}
2021+
Some(CompareMode::SplitDwarf) => {
2022+
rustc.args(&["-Csplit-debuginfo=unpacked"]);
2023+
}
20212024
Some(CompareMode::SplitDwarfSingle) => {
2022-
rustc.args(&["-Csplit-debuginfo=packed", "-Zunstable-options"]);
2025+
rustc.args(&["-Csplit-debuginfo=packed"]);
20232026
}
20242027
None => {}
20252028
}

0 commit comments

Comments
 (0)