diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -598,6 +598,7 @@ Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path); Options.MCOptions.Argv0 = CodeGenOpts.Argv0; Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs; + Options.DebugStrictDwarf = CodeGenOpts.DebugStrictDwarf; return true; } diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -140,6 +140,8 @@ bool getXRayOmitFunctionIndex(); +bool getDebugStrictDwarf(); + /// Create this object with static storage to register codegen-related command /// line options. struct RegisterCodeGenFlags { diff --git a/llvm/include/llvm/Target/TargetOptions.h b/llvm/include/llvm/Target/TargetOptions.h --- a/llvm/include/llvm/Target/TargetOptions.h +++ b/llvm/include/llvm/Target/TargetOptions.h @@ -141,6 +141,7 @@ SupportsDebugEntryValues(false), EnableDebugEntryValues(false), PseudoProbeForProfiling(false), ValueTrackingVariableLocations(false), ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false), + DebugStrictDwarf(false), FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {} /// DisableFramePointerElim - This returns true if frame pointer elimination @@ -331,6 +332,10 @@ /// Emit XRay Function Index section unsigned XRayOmitFunctionIndex : 1; + /// When set to true, don't use DWARF extensions in later DWARF versions. + /// By default, it is set to false. + unsigned DebugStrictDwarf : 1; + /// Stack protector guard offset to use. unsigned StackProtectorGuardOffset = -1U; diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -96,6 +96,7 @@ CGOPT(bool, ValueTrackingVariableLocations) CGOPT(bool, ForceDwarfFrameSection) CGOPT(bool, XRayOmitFunctionIndex) +CGOPT(bool, DebugStrictDwarf) codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { #define CGBINDOPT(NAME) \ @@ -470,6 +471,11 @@ cl::init(false)); CGBINDOPT(XRayOmitFunctionIndex); + static cl::opt DebugStrictDwarf( + "strict-dwarf", cl::desc("use strict dwarf"), + cl::init(false)); + CGBINDOPT(DebugStrictDwarf); + #undef CGBINDOPT mc::RegisterMCTargetOptionsFlags(); @@ -566,6 +572,7 @@ Options.ValueTrackingVariableLocations = getValueTrackingVariableLocations(); Options.ForceDwarfFrameSection = getForceDwarfFrameSection(); Options.XRayOmitFunctionIndex = getXRayOmitFunctionIndex(); + Options.DebugStrictDwarf = getDebugStrictDwarf(); Options.MCOptions = mc::InitMCTargetOptionsFromFlags();