From 2b99b9fd25df59eb8b483e9809185f28d28199ed Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Sun, 15 Jan 2023 09:40:46 -0800 Subject: [PATCH] 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. --- compiler/rustc_codegen_ssa/src/back/link.rs | 6 ------ compiler/rustc_session/src/config.rs | 12 ------------ tests/run-make-fulldeps/split-debuginfo/Makefile | 4 ++-- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs index 342abf81f6a..5715bcf1f11 100644 --- a/compiler/rustc_codegen_ssa/src/back/link.rs +++ b/compiler/rustc_codegen_ssa/src/back/link.rs @@ -1300,12 +1300,6 @@ fn preserve_objects_for_their_debuginfo(sess: &Session) -> (bool, bool) { return (false, false); } - // If we're only producing artifacts that are archives, no need to preserve - // the objects as they're losslessly contained inside the archives. - if sess.crate_types().iter().all(|&x| x.is_archive()) { - return (false, false); - } - match (sess.split_debuginfo(), sess.opts.unstable_opts.split_dwarf_kind) { // If there is no split debuginfo then do not preserve objects. (SplitDebuginfo::Off, _) => (false, false), diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 55576b4e0d1..46ae9b56a48 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -846,18 +846,6 @@ pub enum CrateType { ProcMacro, } -impl CrateType { - /// When generated, is this crate type an archive? - pub fn is_archive(&self) -> bool { - match *self { - CrateType::Rlib | CrateType::Staticlib => true, - CrateType::Executable | CrateType::Dylib | CrateType::Cdylib | CrateType::ProcMacro => { - false - } - } - } -} - #[derive(Clone, Hash, Debug, PartialEq, Eq)] pub enum Passes { Some(Vec), diff --git a/tests/run-make-fulldeps/split-debuginfo/Makefile b/tests/run-make-fulldeps/split-debuginfo/Makefile index 1831ab38fab..44cda0d3d11 100644 --- a/tests/run-make-fulldeps/split-debuginfo/Makefile +++ b/tests/run-make-fulldeps/split-debuginfo/Makefile @@ -254,12 +254,12 @@ unpacked-remapped-single: $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o + rm $(TMPDIR)/*.o ls $(TMPDIR)/*.dwo && exit 1 || exit 0 ls $(TMPDIR)/*.dwp && exit 1 || exit 0 rm $(TMPDIR)/$(call BIN,foo) -unpacked-crosscrate: packed-crosscrate-split packed-crosscrate-single +unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single # - Debuginfo in `.dwo` files # - (bar) `.rlib` file created, contains `.dwo`