]> granicus.if.org Git - clang/commitdiff
We want the dwarf AT_producer for assembly source files to match clang's
authorKevin Enderby <enderby@apple.com>
Thu, 17 Jan 2013 21:38:06 +0000 (21:38 +0000)
committerKevin Enderby <enderby@apple.com>
Thu, 17 Jan 2013 21:38:06 +0000 (21:38 +0000)
AT_producer.  Which includes clang's version information so we can tell
which version of the compiler was used.

This is second of the two steps to allow us to do this.  The first was a
change to llvm-mc with revision 172630 to provide a method to set the
AT_producer string.  This second step has the clang driver passing the value
of getClangFullVersion() via the new flag -dwarf-debug-producer when invoking
the integrated assembler on assembly source files.  Then using the new
setDwarfDebugProducer() method to set the AT_producer string.

rdar://12888242

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172758 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/CC1AsOptions.td
lib/Driver/Tools.cpp
test/Driver/darwin-debug-flags.c
test/Driver/debug-options-as.c
tools/driver/cc1as_main.cpp

index 6a91e0cf8c1441251a5b7951e8fd5aa03b9d0994..2749bcd7779c3ee38be9021141919a37311181e7 100644 (file)
@@ -93,3 +93,6 @@ def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
 
 def dwarf_debug_flags : Separate<["-"], "dwarf-debug-flags">,
   HelpText<"The string to embed in the Dwarf debug flags record.">;
+
+def dwarf_debug_producer : Separate<["-"], "dwarf-debug-producer">,
+  HelpText<"The string to embed in the Dwarf debug AT_producer record.">;
index 372af794044aa0b4a7a612b025209fa3f5223cc1..3fbcd9498d1c4221282e66e9de87f33af29493a8 100644 (file)
@@ -12,6 +12,7 @@
 #include "SanitizerArgs.h"
 #include "ToolChains.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/Version.h"
 #include "clang/Driver/Action.h"
 #include "clang/Driver/Arg.h"
 #include "clang/Driver/ArgList.h"
@@ -3341,6 +3342,11 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
 
     // Add the -fdebug-compilation-dir flag if needed.
     addDebugCompDirArg(Args, CmdArgs);
+
+    // Set the AT_producer to the clang version when using the integrated
+    // assembler on assembly source files.
+    CmdArgs.push_back("-dwarf-debug-producer");
+    CmdArgs.push_back(Args.MakeArgString(getClangFullVersion()));
   }
 
   // Optionally embed the -cc1as level arguments into the debug info, for build
index baf28475f8e8d023d745bb9162f32af11d026b07..f98e9ce7bd8cd68272c53d068f65c39f4872eb7f 100644 (file)
@@ -2,6 +2,8 @@
 // <rdar://problem/7256886>
 // RUN: touch %t.s
 // RUN: env RC_DEBUG_OPTIONS=1 %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s
+// <rdar://problem/12955296>
+// RUN: %clang -### -target i386-apple-darwin9 -c -g %t.s 2>&1 | FileCheck -check-prefix=P %s
 
 // CHECK: !0 = metadata !{
 // CHECK: -g -Os
@@ -11,3 +13,5 @@
 int x;
 
 // S: "-dwarf-debug-flags"
+
+// P: "-dwarf-debug-producer"
index f512f1523bc79a93b1bae285649deefe340c9ff3..0b639b2959cb7d9cd4f682ba53d4290c33214458 100644 (file)
 //
 // CHECK: "-cc1as"
 // CHECK: "-g"
+
+// Check to make sure clang with -g on a .s file gets passed -dwarf-debug-producer.
+// rdar://12955296
+// RUN: touch %t.s
+// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \
+// RUN:   | FileCheck -check-prefix=P %s
+//
+// P: "-cc1as"
+// P: "-dwarf-debug-producer"
index 6f1c8afaa2fe23e4ec51c74a4bbe677c925f2f55..726af19af6c4f54f0de7f84cc8ed9f74c7182cf1 100644 (file)
@@ -83,6 +83,7 @@ struct AssemblerInvocation {
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   std::string DwarfDebugFlags;
+  std::string DwarfDebugProducer;
   std::string DebugCompilationDir;
   std::string MainFileName;
 
@@ -183,6 +184,7 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
   Opts.SaveTemporaryLabels = Args->hasArg(OPT_L);
   Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
   Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
+  Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
   Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
   Opts.MainFileName = Args->getLastArgValue(OPT_main_file_name);
 
@@ -309,6 +311,8 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
     Ctx.setGenDwarfForAssembly(true);
   if (!Opts.DwarfDebugFlags.empty())
     Ctx.setDwarfDebugFlags(StringRef(Opts.DwarfDebugFlags));
+  if (!Opts.DwarfDebugProducer.empty())
+    Ctx.setDwarfDebugProducer(StringRef(Opts.DwarfDebugProducer));
   if (!Opts.DebugCompilationDir.empty())
     Ctx.setCompilationDir(Opts.DebugCompilationDir);
   if (!Opts.MainFileName.empty())