Skip to content

Commit 2b99b9f

Browse files
committed
Preserve split DWARF files when building archives.
The optimization that removes artifacts when building libraries is correct from the compiler's perspective but not from a debugger's perspective. Unpacked split debuginfo is referred to by filename and debuggers need the artifact that contains debuginfo to continue to exist at that path. Ironically the test expects the correct behavior but it was not running.
1 parent 754f6d4 commit 2b99b9f

File tree

3 files changed

+2
-20
lines changed

3 files changed

+2
-20
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1300,12 +1300,6 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> (bool, bool) {
13001300
return (false, false);
13011301
}
13021302

1303-
// If we're only producing artifacts that are archives, no need to preserve
1304-
// the objects as they're losslessly contained inside the archives.
1305-
if sess.crate_types().iter().all(|&x| x.is_archive()) {
1306-
return (false, false);
1307-
}
1308-
13091303
match (sess.split_debuginfo(), sess.opts.unstable_opts.split_dwarf_kind) {
13101304
// If there is no split debuginfo then do not preserve objects.
13111305
(SplitDebuginfo::Off, _) => (false, false),

compiler/rustc_session/src/config.rs

-12
Original file line numberDiff line numberDiff line change
@@ -846,18 +846,6 @@ pub enum CrateType {
846846
ProcMacro,
847847
}
848848

849-
impl CrateType {
850-
/// When generated, is this crate type an archive?
851-
pub fn is_archive(&self) -> bool {
852-
match *self {
853-
CrateType::Rlib | CrateType::Staticlib => true,
854-
CrateType::Executable | CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => {
855-
false
856-
}
857-
}
858-
}
859-
}
860-
861849
#[derive(Clone, Hash, Debug, PartialEq, Eq)]
862850
pub enum Passes {
863851
Some(Vec<String>),

tests/run-make-fulldeps/split-debuginfo/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ unpacked-remapped-single:
254254
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
255255
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g
256256
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
257-
ls $(TMPDIR)/*.o
257+
rm $(TMPDIR)/*.o
258258
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
259259
ls $(TMPDIR)/*.dwp && exit 1 || exit 0
260260
rm $(TMPDIR)/$(call BIN,foo)
261261

262-
unpacked-crosscrate: packed-crosscrate-split packed-crosscrate-single
262+
unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single
263263

264264
# - Debuginfo in `.dwo` files
265265
# - (bar) `.rlib` file created, contains `.dwo`

0 commit comments

Comments
 (0)