forked from OSchip/llvm-project
[Driver] Don't make -gsplit-dwarf imply -g2
RFC: http://lists.llvm.org/pipermail/cfe-dev/2020-May/065430.html Agreement from GCC: https://sourceware.org/pipermail/gcc-patches/2020-May/545688.html g_flags_Group options generally don't affect the amount of debugging information. -gsplit-dwarf is an exception. Its order dependency with other gN_Group options make it inconvenient in a build system: * -g0 -gsplit-dwarf -> level 2 -gsplit-dwarf "upgrades" the amount of debugging information despite the previous intention (-g0) to drop debugging information * -g1 -gsplit-dwarf -> level 2 -gsplit-dwarf "upgrades" the amount of debugging information. * If we have a higher-level -gN, -gN -gsplit-dwarf will supposedly decrease the amount of debugging information. This happens with GCC -g3. The non-orthogonality has confused many users. GCC 11 will change the semantics (-gsplit-dwarf no longer implies -g2) despite the backwards compatibility break. This patch matches its behavior. New semantics: * If there is a g_Group, allow split DWARF if useful (none of: -g0, -gline-directives-only, -g1 -fno-split-dwarf-inlining) * Otherwise, no-op. To restore the original behavior, replace -gsplit-dwarf with -gsplit-dwarf -g. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D80391
This commit is contained in:
parent
4c69b1b98a
commit
843f2dbf00
|
@ -117,6 +117,7 @@ Modified Compiler Flags
|
|||
- Now that `this` pointers are tagged with `nonnull` and `dereferenceable(N)`,
|
||||
`-fno-delete-null-pointer-checks` has gained the power to remove the
|
||||
`nonnull` attribute on `this` for configurations that need it to be nullable.
|
||||
- ``-gsplit-dwarf`` no longer implies ``-g2``.
|
||||
|
||||
New Pragmas in Clang
|
||||
--------------------
|
||||
|
|
|
@ -3750,20 +3750,15 @@ static void RenderDebugOptions(const ToolChain &TC, const Driver &D,
|
|||
Args.hasFlag(options::OPT_fsplit_dwarf_inlining,
|
||||
options::OPT_fno_split_dwarf_inlining, false);
|
||||
|
||||
Args.ClaimAllArgs(options::OPT_g_Group);
|
||||
if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
|
||||
Arg *SplitDWARFArg;
|
||||
DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg);
|
||||
if (DwarfFission != DwarfFissionKind::None &&
|
||||
!checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) {
|
||||
DwarfFission = DwarfFissionKind::None;
|
||||
SplitDWARFInlining = false;
|
||||
}
|
||||
|
||||
Arg* SplitDWARFArg;
|
||||
DwarfFission = getDebugFissionKind(D, Args, SplitDWARFArg);
|
||||
|
||||
if (DwarfFission != DwarfFissionKind::None &&
|
||||
!checkDebugInfoOption(SplitDWARFArg, Args, D, TC)) {
|
||||
DwarfFission = DwarfFissionKind::None;
|
||||
SplitDWARFInlining = false;
|
||||
}
|
||||
|
||||
if (const Arg *A =
|
||||
Args.getLastArg(options::OPT_g_Group, options::OPT_gsplit_dwarf,
|
||||
options::OPT_gsplit_dwarf_EQ)) {
|
||||
DebugInfoKind = codegenoptions::LimitedDebugInfo;
|
||||
|
||||
// If the last option explicitly specified a debug-info level, use it.
|
||||
|
@ -4896,7 +4891,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
if (D.IsCLMode())
|
||||
AddClangCLArgs(Args, InputType, CmdArgs, &DebugInfoKind, &EmitCodeView);
|
||||
|
||||
DwarfFissionKind DwarfFission;
|
||||
DwarfFissionKind DwarfFission = DwarfFissionKind::None;
|
||||
RenderDebugOptions(TC, D, RawTriple, Args, EmitCodeView, CmdArgs,
|
||||
DebugInfoKind, DwarfFission);
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
// RUN: %clang -### -c -target x86_64-apple-darwin -gsplit-dwarf -g %s 2>&1 | FileCheck %s --check-prefix=NOSPLIT
|
||||
// NOSPLIT-NOT: "-split-dwarf
|
||||
|
||||
/// -gsplit-dwarf currently enables debug fission even without -g.
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=SPLIT
|
||||
/// -gsplit-dwarf is a no-op if no -g is specified.
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=G0
|
||||
|
||||
/// Test -gsplit-dwarf=single.
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g %s 2>&1 | FileCheck %s --check-prefix=SINGLE
|
||||
|
@ -59,8 +59,8 @@
|
|||
/// Interaction with -g0.
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf -g0 -### %s 2>&1 | FileCheck %s --check-prefix=G0
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g0 %s 2>&1 | FileCheck %s --check-prefix=G0
|
||||
// RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=NOINLINE,SPLIT
|
||||
// RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf=single %s 2>&1 | FileCheck %s --check-prefix=SINGLE
|
||||
// RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefixes=G0
|
||||
// RUN: %clang -### -c -target x86_64 -g0 -gsplit-dwarf=single %s 2>&1 | FileCheck %s --check-prefix=G0
|
||||
// RUN: %clang -### -c -target x86_64 -gsplit-dwarf=single -g0 -fsplit-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G0
|
||||
|
||||
// G0-NOT: "-debug-info-kind=
|
||||
|
@ -69,7 +69,7 @@
|
|||
/// Interaction with -g1 (-gmlt).
|
||||
// RUN: %clang -### -S -target x86_64 -gsplit-dwarf -g1 %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
|
||||
// RUN: %clang -### -S -target x86_64 -gsplit-dwarf -g1 -fno-split-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
|
||||
// RUN: %clang -### -S -target x86_64 -gmlt -gsplit-dwarf -fno-split-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=SPLIT
|
||||
// RUN: %clang -### -S -target x86_64 -gmlt -gsplit-dwarf -fno-split-dwarf-inlining %s 2>&1 | FileCheck %s --check-prefix=G1_WITH_SPLIT
|
||||
|
||||
// G1_WITH_SPLIT: "-debug-info-kind=line-tables-only"
|
||||
// G1_WITH_SPLIT: "-split-dwarf-file"
|
||||
|
|
Loading…
Reference in New Issue