Skip to content

Commit 17bdb0f

Browse files
committed
Set default Dwarf Version for -gline-tables-only on Darwin to 2.
We are still using Dwarf Version 2 for Darwin systems, make it consistent with -gline-tables-only. This should fix an internal buildbot. llvm-svn: 195267
1 parent c8160d6 commit 17bdb0f

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

clang/lib/Driver/Tools.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,13 +2600,18 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
26002600
D.CCLogDiagnosticsFilename : "-");
26012601
}
26022602

2603-
// Use the last option from "-g" group. "-gline-tables-only"
2604-
// is preserved, all other debug options are substituted with "-g".
2603+
// Use the last option from "-g" group. "-gline-tables-only" and "-gdwarf-x"
2604+
// are preserved, all other debug options are substituted with "-g".
26052605
Args.ClaimAllArgs(options::OPT_g_Group);
26062606
if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
2607-
if (A->getOption().matches(options::OPT_gline_tables_only))
2607+
if (A->getOption().matches(options::OPT_gline_tables_only)) {
2608+
// FIXME: we should support specifying dwarf version with
2609+
// -gline-tables-only.
26082610
CmdArgs.push_back("-gline-tables-only");
2609-
else if (A->getOption().matches(options::OPT_gdwarf_2))
2611+
// Default is dwarf-2 for darwin.
2612+
if (getToolChain().getTriple().isOSDarwin())
2613+
CmdArgs.push_back("-gdwarf-2");
2614+
} else if (A->getOption().matches(options::OPT_gdwarf_2))
26102615
CmdArgs.push_back("-gdwarf-2");
26112616
else if (A->getOption().matches(options::OPT_gdwarf_3))
26122617
CmdArgs.push_back("-gdwarf-3");

clang/test/Driver/debug-options.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
//
3636
// RUN: %clang -### -c -gline-tables-only %s 2>&1 \
3737
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
38+
// RUN: %clang -### -c -gline-tables-only %s -target x86_64-apple-darwin 2>&1 \
39+
// RUN: | FileCheck -check-prefix=GLTO_ONLY_DARWIN %s
3840
// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
3941
// RUN: | FileCheck -check-prefix=G_ONLY %s
4042
// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin 2>&1 \
@@ -66,6 +68,12 @@
6668
// GLTO_ONLY: "-gline-tables-only"
6769
// GLTO_ONLY-NOT: "-g"
6870
//
71+
// GLTO_ONLY_DARWIN: "-cc1"
72+
// GLTO_ONLY_DARWIN-NOT: "-g"
73+
// GLTO_ONLY_DARWIN: "-gline-tables-only"
74+
// GLTO_ONLY_DARWIN: "-gdwarf-2"
75+
// GLTO_ONLY_DARWIN-NOT: "-g"
76+
//
6977
// G_ONLY: "-cc1"
7078
// G_ONLY-NOT: "-gline-tables-only"
7179
// G_ONLY: "-g"

0 commit comments

Comments
 (0)