summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2016-10-17 19:36:18 +0000
committerAdrian Prantl <aprantl@apple.com>2016-10-17 19:36:18 +0000
commitd50d56c774c37df460f5c4f1f33c48d4bb326545 (patch)
tree3ecd2a7cca483ca7eaac0508a330af94c081479e
parent018a3afa99573586646e36d6e3e20e59975466bb (diff)
downloadbcm5719-llvm-d50d56c774c37df460f5c4f1f33c48d4bb326545.tar.gz
bcm5719-llvm-d50d56c774c37df460f5c4f1f33c48d4bb326545.zip
Driver/Darwin: Set the DWARF version based on the deployment target.
System utilities such as atos only support DWARF 4 on OS X 10.11+ and iOS 9+. We thus want to enable DWARF 4 only if the deployment target has a recent enough operating system version and use DWARF 2 for older systems. <rdar://problem/28766743> llvm-svn: 284416
-rw-r--r--clang/lib/Driver/ToolChains.cpp8
-rw-r--r--clang/lib/Driver/ToolChains.h2
-rw-r--r--clang/test/Driver/clang-g-opts.c4
-rw-r--r--clang/test/Driver/debug-options.c47
4 files changed, 40 insertions, 21 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index a9fd7ee7195..1afe6e45255 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -289,6 +289,14 @@ void DarwinClang::AddLinkARCArgs(const ArgList &Args,
CmdArgs.push_back(Args.MakeArgString(P));
}
+unsigned DarwinClang::GetDefaultDwarfVersion() const {
+ // Default to use DWARF 2 on OS X 10.10 / iOS 8 and lower.
+ if ((isTargetMacOS() && isMacosxVersionLT(10, 11)) ||
+ (isTargetIOSBased() && isIPhoneOSVersionLT(9)))
+ return 2;
+ return 4;
+}
+
void MachO::AddLinkRuntimeLib(const ArgList &Args, ArgStringList &CmdArgs,
StringRef DarwinLibName, bool AlwaysLink,
bool IsEmbedded, bool AddRPath) const {
diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h
index 0838208e3be..c4c054dead6 100644
--- a/clang/lib/Driver/ToolChains.h
+++ b/clang/lib/Driver/ToolChains.h
@@ -585,7 +585,7 @@ public:
void AddLinkARCArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
- unsigned GetDefaultDwarfVersion() const override { return 4; }
+ unsigned GetDefaultDwarfVersion() const override;
// Until dtrace (via CTF) and LLDB can deal with distributed debug info,
// Darwin defaults to standalone/full debug info.
bool GetDefaultStandaloneDebug() const override { return true; }
diff --git a/clang/test/Driver/clang-g-opts.c b/clang/test/Driver/clang-g-opts.c
index 21b5cf645d0..a26fb29652b 100644
--- a/clang/test/Driver/clang-g-opts.c
+++ b/clang/test/Driver/clang-g-opts.c
@@ -4,7 +4,7 @@
// Assert that the toolchains which should default to a lower Dwarf version do so.
// RUN: %clang -### -S %s -g -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-WITH-G-STANDALONE %s
+// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
// RUN: %clang -### -S %s -g -target i686-pc-openbsd 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WITH-G-DWARF2 %s
// RUN: %clang -### -S %s -g -target x86_64-pc-freebsd10.0 2>&1 \
@@ -36,4 +36,4 @@
// CHECK-WITH-G-DWARF2: "-dwarf-version=2"
// CHECK-WITH-G-STANDALONE: "-debug-info-kind=standalone"
-// CHECK-WITH-G-STANDALONE: "-dwarf-version=4"
+// CHECK-WITH-G-STANDALONE: "-dwarf-version=2"
diff --git a/clang/test/Driver/debug-options.c b/clang/test/Driver/debug-options.c
index 0702811ae84..ec21bfe3dae 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -19,17 +19,31 @@
// RUN: | FileCheck -check-prefix=G -check-prefix=G_SCE %s
// RUN: %clang -### -c -g %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_LLDB %s
-// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=G_DARWIN %s
-// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=G_DARWIN %s
-// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=G_DARWIN -check-prefix=G_GDB %s
-// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 -check-prefix=G_LLDB %s
+// RUN: %clang -### -c -g %s -target x86_64-apple-darwin16 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 -check-prefix=G_LLDB %s
+// RUN: %clang -### -c -g2 %s -target x86_64-apple-darwin16 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -g3 %s -target x86_64-apple-darwin16 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -ggdb %s -target x86_64-apple-darwin16 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 -check-prefix=G_GDB %s
+// RUN: %clang -### -c -ggdb1 %s -target x86_64-apple-darwin16 2>&1 \
// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
-// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin 2>&1 \
-// RUN: | FileCheck -check-prefix=G_DARWIN %s
+// RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin16 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.11 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -g %s -target x86_64-apple-macosx10.10 2>&1 \
+// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
+// RUN: %clang -### -c -g %s -target armv7-apple-ios9.0 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -g %s -target armv7-apple-ios8.0 2>&1 \
+// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
+// RUN: %clang -### -c -g %s -target armv7k-apple-watchos 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
+// RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
// RUN: | FileCheck -check-prefix=G_GDB %s
@@ -75,7 +89,7 @@
// RUN: | FileCheck -check-prefix=GLTO_ONLY_DWARF2 %s
// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-linux-gnu 2>&1 \
// RUN: | FileCheck -check-prefix=G_ONLY %s
-// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin 2>&1 \
+// RUN: %clang -### -c -gline-tables-only -g %s -target x86_64-apple-darwin16 2>&1 \
// RUN: | FileCheck -check-prefix=G_STANDALONE_DWARF4 %s
// RUN: %clang -### -c -gline-tables-only -g %s -target i686-pc-openbsd 2>&1 \
// RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
@@ -121,9 +135,6 @@
// G: "-cc1"
// G: "-debug-info-kind=limited"
//
-// G_DARWIN: "-cc1"
-// G_DARWIN: "-dwarf-version=4"
-//
// NOG_PS4: "-cc1"
// NOG_PS4-NOT "-dwarf-version=
// NOG_PS4: "-generate-arange-section"
@@ -151,10 +162,6 @@
// G_ONLY: "-cc1"
// G_ONLY: "-debug-info-kind=limited"
//
-// G_GDB: "-debugger-tuning=gdb"
-// G_LLDB: "-debugger-tuning=lldb"
-// G_SCE: "-debugger-tuning=sce"
-//
// These tests assert that "-gline-tables-only" "-g" uses the latter,
// but otherwise not caring about the DebugInfoKind.
// G_ONLY_DWARF2: "-cc1"
@@ -165,6 +172,10 @@
// G_STANDALONE_DWARF4: "-debug-info-kind=standalone"
// G_STANDALONE_DWARF4: "-dwarf-version=4"
//
+// G_GDB: "-debugger-tuning=gdb"
+// G_LLDB: "-debugger-tuning=lldb"
+// G_SCE: "-debugger-tuning=sce"
+//
// This tests asserts that "-gline-tables-only" "-g0" disables debug info.
// GLTO_NO: "-cc1"
// GLTO_NO-NOT: -debug-info-kind=
OpenPOWER on IntegriCloud