@ikudrin enabled support for dwarf64 in D87011. Adding a clang flag so it can be used through that compilation pass.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D90507
llvm::DebugCompressionType::None)
CODEGENOPT(RelaxELFRelocations, 1, 0) ///< -Wa,--mrelax-relocations
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
+CODEGENOPT(Dwarf64 , 1, 0) ///< -gdwarf64.
+CODEGENOPT(Dwarf32 , 1, 1) ///< -gdwarf32.
CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
CODEGENOPT(Autolink , 1, 1) ///< -fno-autolink
HelpText<"Generate source-level debug information with dwarf version 4">;
def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group<g_Group>,
HelpText<"Generate source-level debug information with dwarf version 5">;
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group<g_Group>, Flags<[CC1Option]>,
+ HelpText<"Enables DWARF64 format for ELF binaries, if debug information emission is enabled.">;
+def gdwarf32 : Flag<["-"], "gdwarf32">, Group<g_Group>, Flags<[CC1Option]>,
+ HelpText<"Enables DWARF32 format for ELF binaries, if debug information emission is enabled.">;
def gcodeview : Flag<["-"], "gcodeview">,
HelpText<"Generate CodeView debug information">,
Options.MCOptions.MCFatalWarnings = CodeGenOpts.FatalWarnings;
Options.MCOptions.MCNoWarn = CodeGenOpts.NoWarn;
Options.MCOptions.AsmVerbose = CodeGenOpts.AsmVerbose;
+ Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
Options.MCOptions.ABIName = TargetOpts.ABI;
for (const auto &Entry : HSOpts.UserEntries)
if (DebuggerTuning == llvm::DebuggerKind::SCE)
CmdArgs.push_back("-dwarf-explicit-import");
+ auto *DwarfFormatArg =
+ Args.getLastArg(options::OPT_gdwarf64, options::OPT_gdwarf32);
+ if (DwarfFormatArg &&
+ DwarfFormatArg->getOption().matches(options::OPT_gdwarf64)) {
+ const llvm::Triple &RawTriple = TC.getTriple();
+ if (EffectiveDWARFVersion < 3)
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << DwarfFormatArg->getAsString(Args) << "DWARFv3 or greater";
+ else if (!RawTriple.isArch64Bit())
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << DwarfFormatArg->getAsString(Args) << "64 bit architecture";
+ else if (!RawTriple.isOSBinFormatELF())
+ D.Diag(diag::err_drv_argument_only_allowed_with)
+ << DwarfFormatArg->getAsString(Args) << "ELF platforms";
+ }
+
+ if (DwarfFormatArg)
+ DwarfFormatArg->render(Args, CmdArgs);
+
RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
}
setPGOUseInstrumentor(Opts, Opts.ProfileInstrumentUsePath);
Opts.CodeModel = TargetOpts.CodeModel;
+ Opts.Dwarf64 = Args.hasArg(OPT_gdwarf64);
if (const Arg *A = Args.getLastArg(OPT_ftime_report, OPT_ftime_report_EQ)) {
Opts.TimePasses = true;
// RUN: | FileCheck -check-prefix=NO_DEBUG_UNUSED_TYPES %s
// NO_DEBUG_UNUSED_TYPES: "-debug-info-kind={{limited|line-tables-only|standalone}}"
// NO_DEBUG_UNUSED_TYPES-NOT: "-debug-info-kind=unused-types"
+//
+// RUN: %clang -### -c -gdwarf-5 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-3 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-2 -gdwarf64 -target x86_64 %s 2>&1 | FileCheck -check-prefix=GDWARF64_VER %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64 -target x86_64 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target i386-linux-gnu %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GDWARF64_32ARCH %s
+// RUN: %clang -### -c -gdwarf-4 -gdwarf64 -target x86_64-apple-darwin %s 2>&1 \
+// RUN: | FileCheck -check-prefix=GDWARF64_ELF %s
+//
+// GDWARF64_ON: "-gdwarf64"
+// GDWARF64_VER: error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
+// GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
+// GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'