Skip to content

Commit 098d901

Browse files
committed
DebugInfo: Let -gdwarf use the toolchain default DWARF version, instead of hardcoded/aliased to -gdwarf-4
1 parent cecc0d2 commit 098d901

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,6 +1972,10 @@ def ggdb2 : Flag<["-"], "ggdb2">, Group<ggdbN_Group>;
19721972
def ggdb3 : Flag<["-"], "ggdb3">, Group<ggdbN_Group>;
19731973
def glldb : Flag<["-"], "glldb">, Group<gTune_Group>;
19741974
def gsce : Flag<["-"], "gsce">, Group<gTune_Group>;
1975+
// Equivalent to our default dwarf version. Forces usual dwarf emission when
1976+
// CodeView is enabled.
1977+
def gdwarf : Flag<["-"], "gdwarf">, Group<g_Group>,
1978+
HelpText<"Generate source-level debug information with the default dwarf version">;
19751979
def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group<g_Group>,
19761980
HelpText<"Generate source-level debug information with dwarf version 2">;
19771981
def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group<g_Group>,
@@ -1989,10 +1993,6 @@ def gcodeview_ghash : Flag<["-"], "gcodeview-ghash">,
19891993
Flags<[CC1Option, CoreOption]>;
19901994
def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, Flags<[CoreOption]>;
19911995

1992-
// Equivalent to our default dwarf version. Forces usual dwarf emission when
1993-
// CodeView is enabled.
1994-
def gdwarf : Flag<["-"], "gdwarf">, Alias<gdwarf_4>, Flags<[CoreOption]>;
1995-
19961996
def gfull : Flag<["-"], "gfull">, Group<g_Group>;
19971997
def gused : Flag<["-"], "gused">, Group<g_Group>;
19981998
def gstabs : Joined<["-"], "gstabs">, Group<g_Group>, Flags<[Unsupported]>;

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3198,9 +3198,9 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
31983198
}
31993199

32003200
// If a -gdwarf argument appeared, remember it.
3201-
const Arg *GDwarfN =
3202-
Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
3203-
options::OPT_gdwarf_4, options::OPT_gdwarf_5);
3201+
const Arg *GDwarfN = Args.getLastArg(
3202+
options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
3203+
options::OPT_gdwarf_5, options::OPT_gdwarf);
32043204
bool EmitDwarf = false;
32053205
if (GDwarfN) {
32063206
if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -3231,6 +3231,7 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
32313231
if (EmitDwarf) {
32323232
// Start with the platform default DWARF version
32333233
DWARFVersion = TC.GetDefaultDwarfVersion();
3234+
assert(DWARFVersion && "toolchain default DWARF version must be nonzero");
32343235

32353236
// Override with a user-specified DWARF version
32363237
if (GDwarfN)

clang/test/CodeGen/dwarf-version.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
1515
// RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
1616
// RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
17+
// RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | FileCheck %s --check-prefix=VER2
1718

1819
// Check which debug info formats we use on Windows. By default, in an MSVC
1920
// environment, we should use codeview. You can enable dwarf, which implicitly

0 commit comments

Comments
 (0)