[PATCH] D59673: [Driver] Allow setting the DWO name DWARF attribute separately

Aaron Puchert via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 21 15:22:04 PDT 2019


aaronpuchert created this revision.
aaronpuchert added reviewers: dblaikie, echristo.
Herald added subscribers: cfe-commits, jdoerfert, aprantl.
Herald added a project: clang.

With Split DWARF the resulting object file (then called skeleton CU)
contains the file name of another ("DWO") file with the debug info.
This is a problem for remote compilation, as the file name written there
will be that of the compilation server, not of the client.

To reliably enable Split DWARF in the case of of remote compilation, we
need the ability to inject arbitrary file names into this field, which
is now provided by the option

  -fsplit-dwarf-dwo-name-attr=<file>

For now we keep this as CC1 option, but the idea is to promote it
eventually, if it picks up.


Repository:
  rC Clang

https://reviews.llvm.org/D59673

Files:
  include/clang/Basic/CodeGenOptions.h
  include/clang/Driver/Options.td
  lib/CodeGen/BackendUtil.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/split-debug-dwo-name-attr.c


Index: test/CodeGen/split-debug-dwo-name-attr.c
===================================================================
--- /dev/null
+++ test/CodeGen/split-debug-dwo-name-attr.c
@@ -0,0 +1,8 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -enable-split-dwarf -fdebug-compilation-dir /foo -fsplit-dwarf-dwo-name-attr=bar.dwo -split-dwarf-file %t -emit-obj -o - %s | llvm-objdump -s -section=.debug_str - | FileCheck %s
+// RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=DWO %s
+
+int f() { return 0; }
+
+// CHECK: 0000 2f666f6f 00626172 2e64776f 00        /foo.bar.dwo.
+// DWO: .dwo
Index: lib/Frontend/CompilerInvocation.cpp
===================================================================
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -714,6 +714,8 @@
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);
   Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);
+  Opts.SplitDwarfDwoNameAttr =
+      Args.getLastArgValue(OPT_fsplit_dwarf_dwo_name_attr_EQ);
   Opts.SplitDwarfInlining = !Args.hasArg(OPT_fno_split_dwarf_inlining);
 
   if (Arg *A =
Index: lib/CodeGen/BackendUtil.cpp
===================================================================
--- lib/CodeGen/BackendUtil.cpp
+++ lib/CodeGen/BackendUtil.cpp
@@ -464,7 +464,9 @@
   Options.EmitAddrsig = CodeGenOpts.Addrsig;
 
   if (CodeGenOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
-    Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
+    Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfDwoNameAttr.empty()
+                                           ? CodeGenOpts.SplitDwarfFile
+                                           : CodeGenOpts.SplitDwarfDwoNameAttr;
   Options.MCOptions.MCRelaxAll = CodeGenOpts.RelaxAll;
   Options.MCOptions.MCSaveTempLabels = CodeGenOpts.SaveTempLabels;
   Options.MCOptions.MCUseDwarfDirectory = !CodeGenOpts.NoDwarfDirectoryAsm;
Index: include/clang/Driver/Options.td
===================================================================
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1849,6 +1849,8 @@
   Flags<[CC1Option]>, HelpText<"Use DWARF base address selection entries in debug_ranges">;
 def fno_debug_ranges_base_address: Flag <["-"], "fno-debug-ranges-base-address">, Group<f_Group>,
   Flags<[CC1Option]>;
+def fsplit_dwarf_dwo_name_attr_EQ: Joined<["-"], "fsplit-dwarf-dwo-name-attr=">, Group<f_Group>,
+  Flags<[CC1Option]>, HelpText<"Set the name for the split debug info file to be used in the object file">;
 def fsplit_dwarf_inlining: Flag <["-"], "fsplit-dwarf-inlining">, Group<f_Group>,
   Flags<[CC1Option]>, HelpText<"Provide minimal debug info in the object/executable to facilitate online symbolication/stack traces in the absence of .dwo/.dwp files when using Split DWARF">;
 def fno_split_dwarf_inlining: Flag<["-"], "fno-split-dwarf-inlining">, Group<f_Group>,
Index: include/clang/Basic/CodeGenOptions.h
===================================================================
--- include/clang/Basic/CodeGenOptions.h
+++ include/clang/Basic/CodeGenOptions.h
@@ -188,6 +188,10 @@
   /// in the backend for setting the name in the skeleton cu.
   std::string SplitDwarfFile;
 
+  /// Overrides \ref SplitDwarfFile as value of DW_AT_[GNU_]dwo_name to be used
+  /// in the skeleton CU, if not empty. Does not change the output file name.
+  std::string SplitDwarfDwoNameAttr;
+
   /// The name of the relocation model to use.
   llvm::Reloc::Model RelocationModel;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59673.191790.patch
Type: text/x-patch
Size: 3676 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190321/b6ce76a3/attachment-0001.bin>


More information about the cfe-commits mailing list