[PATCH] D84565: [Darwin] [Driver] Clang should invoke dsymutil for lto builds -g*

Chris Bieneman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 24 16:22:23 PDT 2020


beanz created this revision.
beanz added reviewers: bogner, compnerd, aprantl, arphaman.
Herald added subscribers: dexonsmith, inglorion.
Herald added a reviewer: JDevlieghere.
Herald added a project: clang.

Clang should always add a dsymutil step whenever debug information is
generated and the compiler is acting as the linker driver with
temporary object files.

https://bugs.llvm.org/show_bug.cgi?id=46841


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84565

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/darwin-dsymutil.c


Index: clang/test/Driver/darwin-dsymutil.c
===================================================================
--- clang/test/Driver/darwin-dsymutil.c
+++ clang/test/Driver/darwin-dsymutil.c
@@ -47,3 +47,11 @@
 
 // Check that we don't crash when translating arguments for dsymutil.
 // RUN: %clang -m32 -arch x86_64 -g %s -###
+
+// Check that we run dsymutil when -flto is specified and no source is provided
+// RUN: touch %t.o
+// RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
+// RUN:   -arch x86_64 %t.o -g -flto 2> %t
+// RUN: FileCheck -check-prefix=CHECK-DSYMUTIL-LTO < %t %s
+
+// CHECK-DSYMUTIL-LTO: "/usr/bin/dsymutil" "-o" "a.out.dSYM" "a.out"
Index: clang/lib/Driver/Driver.cpp
===================================================================
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2033,13 +2033,17 @@
     Arg *A = Args.getLastArg(options::OPT_g_Group);
     bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
                             !A->getOption().matches(options::OPT_gstabs);
+    bool isGeneratingTemporaryObject =
+        ContainsCompileOrAssembleAction(Actions.back()) || LTOMode != LTOK_None;
     if ((enablesDebugInfo || willEmitRemarks(Args)) &&
-        ContainsCompileOrAssembleAction(Actions.back())) {
+        isGeneratingTemporaryObject) {
 
       // Add a 'dsymutil' step if necessary, when debug info is enabled and we
-      // have a compile input. We need to run 'dsymutil' ourselves in such cases
-      // because the debug info will refer to a temporary object file which
-      // will be removed at the end of the compilation process.
+      // are linking a temporary object. This occurs when we have a compiler
+      // or assmbler input or if LTO is enabled. We need to run 'dsymutil'
+      // ourselves in such cases because the debug info will refer to the
+      // temporary object file which will be removed at the end of the
+      // compilation process.
       if (Act->getType() == types::TY_Image) {
         ActionList Inputs;
         Inputs.push_back(Actions.back());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84565.280616.patch
Type: text/x-patch
Size: 2107 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200724/e1d04d99/attachment.bin>


More information about the cfe-commits mailing list