[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 18:00:08 PDT 2020


beanz updated this revision to Diff 280641.
beanz added a comment.

Fixing bad test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84565/new/

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: x86_64-apple-darwin10" - "darwin::Dsymutil", inputs: ["a.out"], output: "a.out.dSYM"
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.280641.patch
Type: text/x-patch
Size: 2146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200725/8143b7c5/attachment.bin>


More information about the cfe-commits mailing list