aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/Driver/CC1AsOptions.td3
-rw-r--r--lib/Driver/Tools.cpp6
-rw-r--r--test/Driver/darwin-debug-flags.c4
-rw-r--r--test/Driver/debug-options-as.c9
-rw-r--r--tools/driver/cc1as_main.cpp4
5 files changed, 26 insertions, 0 deletions
diff --git a/include/clang/Driver/CC1AsOptions.td b/include/clang/Driver/CC1AsOptions.td
index 6a91e0cf8c..2749bcd777 100644
--- a/include/clang/Driver/CC1AsOptions.td
+++ b/include/clang/Driver/CC1AsOptions.td
@@ -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.">;
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 372af79404..3fbcd9498d 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -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
diff --git a/test/Driver/darwin-debug-flags.c b/test/Driver/darwin-debug-flags.c
index baf28475f8..f98e9ce7bd 100644
--- a/test/Driver/darwin-debug-flags.c
+++ b/test/Driver/darwin-debug-flags.c
@@ -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"
diff --git a/test/Driver/debug-options-as.c b/test/Driver/debug-options-as.c
index f512f1523b..0b639b2959 100644
--- a/test/Driver/debug-options-as.c
+++ b/test/Driver/debug-options-as.c
@@ -18,3 +18,12 @@
//
// 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"
diff --git a/tools/driver/cc1as_main.cpp b/tools/driver/cc1as_main.cpp
index 6f1c8afaa2..726af19af6 100644
--- a/tools/driver/cc1as_main.cpp
+++ b/tools/driver/cc1as_main.cpp
@@ -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())