def g : Flag<["-"], "g">, HelpText<"Generate source level debug information">;
+def gdwarf_2 : Flag<["-"], "gdwarf-2">,
+ HelpText<"Generate source level debug information with dwarf version 2">;
+def gdwarf_3 : Flag<["-"], "gdwarf-3">,
+ HelpText<"Generate source level debug information with dwarf version 3">;
+def gdwarf_4 : Flag<["-"], "gdwarf-4">,
+ HelpText<"Generate source level debug information with dwarf version 4">;
+
def fdebug_compilation_dir : Separate<["-"], "fdebug-compilation-dir">,
HelpText<"The compilation directory to embed in the debug info.">;
// -I. The next arg will be the include directory.
if (Value == "-I")
TakeNextArg = true;
+ } else if (Value.startswith("-gdwarf-")) {
+ CmdArgs.push_back(Value.data());
} else {
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getOption().getName() << Value;
if (!A->getOption().matches(options::OPT_g0))
CmdArgs.push_back("-g");
+ if (Args.hasArg(options::OPT_gdwarf_2))
+ CmdArgs.push_back("-gdwarf-2");
+ if (Args.hasArg(options::OPT_gdwarf_3))
+ CmdArgs.push_back("-gdwarf-3");
+ if (Args.hasArg(options::OPT_gdwarf_4))
+ CmdArgs.push_back("-gdwarf-4");
+
// Add the -fdebug-compilation-dir flag if needed.
addDebugCompDirArg(Args, CmdArgs);
// XA_INCLUDE2: cc1as
// XA_INCLUDE2: "-Ifoo_dir"
+// RUN: %clang -### -c -integrated-as %s -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2 %s
+// DWARF2: "-g" "-gdwarf-2"
+
+// RUN: %clang -### -c -integrated-as %s -gdwarf-3 2>&1 | FileCheck --check-prefix=DWARF3 %s
+// DWARF3: "-g" "-gdwarf-3"
+
+// RUN: %clang -### -c -integrated-as %s -gdwarf-4 2>&1 | FileCheck --check-prefix=DWARF4 %s
+// DWARF4: "-g" "-gdwarf-4"
+
+// RUN: %clang -### -c -integrated-as %s -Xassembler -gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2XASSEMBLER %s
+// DWARF2XASSEMBLER: "-gdwarf-2"
+
+// RUN: %clang -### -c -integrated-as %s -Wa,-gdwarf-2 2>&1 | FileCheck --check-prefix=DWARF2WA %s
+// DWARF2WA: "-gdwarf-2"
unsigned SaveTemporaryLabels : 1;
unsigned GenDwarfForAssembly : 1;
unsigned CompressDebugSections : 1;
+ unsigned DwarfVersion;
std::string DwarfDebugFlags;
std::string DwarfDebugProducer;
std::string DebugCompilationDir;
ShowEncoding = 0;
RelaxAll = 0;
NoExecStack = 0;
+ DwarfVersion = 3;
}
static bool CreateFromArgs(AssemblerInvocation &Res, const char **ArgBegin,
Opts.SaveTemporaryLabels = Args->hasArg(OPT_msave_temp_labels);
Opts.GenDwarfForAssembly = Args->hasArg(OPT_g);
Opts.CompressDebugSections = Args->hasArg(OPT_compress_debug_sections);
+ if (Args->hasArg(OPT_gdwarf_2))
+ Opts.DwarfVersion = 2;
+ if (Args->hasArg(OPT_gdwarf_3))
+ Opts.DwarfVersion = 3;
+ if (Args->hasArg(OPT_gdwarf_4))
+ Opts.DwarfVersion = 4;
Opts.DwarfDebugFlags = Args->getLastArgValue(OPT_dwarf_debug_flags);
Opts.DwarfDebugProducer = Args->getLastArgValue(OPT_dwarf_debug_producer);
Opts.DebugCompilationDir = Args->getLastArgValue(OPT_fdebug_compilation_dir);
Ctx.setCompilationDir(Opts.DebugCompilationDir);
if (!Opts.MainFileName.empty())
Ctx.setMainFileName(StringRef(Opts.MainFileName));
+ Ctx.setDwarfVersion(Opts.DwarfVersion);
// Build up the feature string from the target feature list.
std::string FS;